Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit 3b30ca8

Browse files
committed
Unescapes characters in urls
1 parent b444fe0 commit 3b30ca8

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

digexp-sp-server/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ function findEndTag(substr) {
116116

117117
}
118118

119+
function unescapeCharacters(str) {
120+
return str.replace(/%(\d+)/g, function(match, dec) {
121+
return String.fromCharCode(parseInt(+dec, 16));
122+
});
123+
}
124+
119125
exports.start = function start(dir, port) {
120126
port = port || DEFAULT_PORT;
121127

@@ -134,7 +140,7 @@ exports.start = function start(dir, port) {
134140
// Special processing for HTML and JS files
135141
app.get(['/*.html', '/*.js'], function(req, res) {
136142
console.log('get ' + req.path);
137-
var filePath = path.join(dir, req.path);
143+
var filePath = unescapeCharacters(path.join(dir, req.path));
138144
// read file contents
139145
fs.readFile(filePath, 'utf8', function(err, contents) {
140146
if (err) {

sp-server.tar.gz

672 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)