Skip to content

Commit

Permalink
Unescape pathname from url when loading from local filesystem
Browse files Browse the repository at this point in the history
When a path contains a space it will be escaped to ’%20’. When loading from local filesystem it has to be converted back to a space to get the correct path.
  • Loading branch information
Martin Carlberg authored and mrcarlberg committed Apr 21, 2021
1 parent bf53329 commit 6a0a91d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function XMLHttpRequest(opts) {
}

if (settings.async) {
fs.readFile(url.pathname, 'utf8', function(error, data) {
fs.readFile(unescape(url.pathname), 'utf8', function(error, data) {
if (error) {
self.handleError(error);
} else {
Expand All @@ -333,7 +333,7 @@ function XMLHttpRequest(opts) {
});
} else {
try {
this.responseText = fs.readFileSync(url.pathname, 'utf8');
this.responseText = fs.readFileSync(unescape(url.pathname), 'utf8');
this.status = 200;
setState(self.DONE);
} catch(e) {
Expand Down

0 comments on commit 6a0a91d

Please sign in to comment.