diff --git a/src/package/index.js b/src/package/index.js index 87ee4a2..403b14a 100644 --- a/src/package/index.js +++ b/src/package/index.js @@ -144,7 +144,7 @@ class Package { paths.push(...['./browser-', './node-'].map(n => n + rel.slice(2))) } } - const code = paths.map(p => `import("${p}")`).join('\n') + const code = paths.map(p => `import("${p.replace(/\\/g, '/')}")`).join('\n') const input = new URL(dist + '/esm/_ipjsInput.js') await writeFile(input, code) const onwarn = warning => { diff --git a/src/path-to-url.js b/src/path-to-url.js index f582e51..d0f0a4e 100644 --- a/src/path-to-url.js +++ b/src/path-to-url.js @@ -1,7 +1,6 @@ // adapted from https://nodejs.org/api/path.html#path_path_resolve_paths const CHAR_FORWARD_SLASH = '/' const percentRegEx = /%/g -const backslashRegEx = /\\/g const newlineRegEx = /\n/g const carriageReturnRegEx = /\r/g const tabRegEx = /\t/g @@ -18,8 +17,6 @@ export default (filepath, cwd) => { resolved[resolved.length - 1] !== '/') { resolved += '/' } const outURL = new URL('file://') if (resolved.includes('%')) { resolved = resolved.replace(percentRegEx, '%25') } - // In posix, "/" is a valid character in paths - if (resolved.includes('\\')) { resolved = resolved.replace(backslashRegEx, '%5C') } if (resolved.includes('\n')) { resolved = resolved.replace(newlineRegEx, '%0A') } if (resolved.includes('\r')) { resolved = resolved.replace(carriageReturnRegEx, '%0D') } if (resolved.includes('\t')) { resolved = resolved.replace(tabRegEx, '%09') }