From 120f05906bb5653b90badb3eba4b0927f49f2128 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 21 Dec 2017 00:15:04 +1100 Subject: [PATCH] Avoid normalising well-formed URIs by default References: Alhadis/Atom-FS#1 --- lib/node.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index 37b361e..18e99e3 100644 --- a/lib/node.js +++ b/lib/node.js @@ -45,11 +45,17 @@ function load(url, encoding = "utf8"){ /** * Normalise path separators. * + * Well-formed URIs (those prefixed by `protocol://`) + * are returned unmodified unless `clobber` is truthy. + * * @example "C:\User\foo\..\bar" -> "C:/User/bar" * @param {String} input + * @param {Boolean} [clobber=false] * @return {String} */ -function normalisePath(input){ +function normalisePath(input, clobber = false){ + if(!clobber && /^\w*:\/\//.test(input)) + return input; input = resolve(input || ""); return "win32" === process.platform ? input.replace(/\\/g, "/")