diff --git a/traque.js b/traque.js index 6d787af..3ed1320 100644 --- a/traque.js +++ b/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(); }); }