legacy replaceAll
This commit is contained in:
parent
7f0b9a517c
commit
cb4d63c6be
1 changed files with 10 additions and 1 deletions
11
traque.js
11
traque.js
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue