Skip to content

Commit

Permalink
Honour root path separators in encoding - fixes #81
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Mar 23, 2018
1 parent ca505ef commit 05d10ef
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions source/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ let fetchMethod = nodeFetch;
* @returns {String} The encoded path (separators protected)
*/
function encodePath(path) {
const replaced = path
.replace(/(^|[^\\])\\\\($|[^\\])/g, "$1" + SEP_PATH_WINDOWS + "$2")
.replace(/(^|[^\/])\/($|[^\/])/g, "$1" + SEP_PATH_POSIX + "$2");
const replaced = path.replace(/\//g, SEP_PATH_POSIX).replace(/\\\\/g, SEP_PATH_WINDOWS);
const formatted = encodeURIComponent(replaced);
return formatted
.split(SEP_PATH_WINDOWS)
Expand Down

0 comments on commit 05d10ef

Please sign in to comment.