Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add readme
Co-authored-by: Rich Trott <rtrott@gmail.com>
  • Loading branch information
bmeck and Trott committed Oct 18, 2020
commit 62c32dc3e422c7f6d22761d3dba6176efb3e115c
7 changes: 4 additions & 3 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ function urlToOptions(url) {
return options;
}

const forwardSlashRegEx = /\//g;
const forwardSlashesRegEx = /\/+/g;

function getPathFromURLWin32(url) {
const hostname = url.hostname;
Expand All @@ -1311,7 +1311,7 @@ function getPathFromURLWin32(url) {
}
}
}
pathname = pathname.replace(forwardSlashRegEx, '\\');
pathname = pathname.replace(forwardSlashesRegEx, '\\');
pathname = decodeURIComponent(pathname);
if (hostname !== '') {
// If hostname is set, then we have a UNC path
Expand All @@ -1336,7 +1336,7 @@ function getPathFromURLPosix(url) {
if (url.hostname !== '') {
throw new ERR_INVALID_FILE_URL_HOST(platform);
}
const pathname = url.pathname;
let pathname = url.pathname;
for (let n = 0; n < pathname.length; n++) {
if (pathname[n] === '%') {
const third = pathname.codePointAt(n + 2) | 0x20;
Expand All @@ -1347,6 +1347,7 @@ function getPathFromURLPosix(url) {
}
}
}
pathname = pathname.replace(forwardSlashesRegEx, '/');
return decodeURIComponent(pathname);
}

Expand Down
5 changes: 5 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ const { spawn } = require('child_process');
spawn(...common.pwdCommand, { stdio: ['pipe'] });
```

### `requireNoPackageJSONAbove()`

Throws an `AssertionError` if a `package.json` file is in any ancestor
directory. Such files may interfere with proper test functionality.

### `runWithInvalidFD(func)`

* `func` [&lt;Function>][]
Expand Down