legacy replaceAll

This commit is contained in:
Sylvain Gay 2023-09-12 11:44:32 +02:00
parent 7f0b9a517c
commit cb4d63c6be

View file

@ -52,6 +52,15 @@ const option = {
cert: fs.readFileSync(config.cert)
};
function replaceAll_legacy(data, pattern, replacement){
var replacing = data.replace(pattern, replacement);
while(replacing != data){
data = replacing;
replacing = data.replace(pattern, replacement);
}
return data;
}
// The server
var server = https.createServer(option, function(req, res){
var q = url.parse(req.url, true);
@ -73,7 +82,7 @@ var server = https.createServer(option, function(req, res){
throw new Error("where " + end_path + " is !?");
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(data.replaceAll("%ID", id).replaceAll("%GPSLOG", gpslog));
res.write(replaceAll_legacy(replaceAll_legacy(data, "%GPSLOG", gpslog), "%ID", id));
return res.end();
});
}