-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from AikidoSec/patch-path
Avoid double wrapping path
- Loading branch information
Showing
4 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isWindows() { | ||
return process.platform === "win32"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { join, normalize, resolve } from "path/posix"; | ||
import * as t from "tap"; | ||
import { isWindows } from "../helpers/isWindows"; | ||
import { isWrapped } from "../helpers/wrap"; | ||
import { Path } from "./Path"; | ||
import { createTestAgent } from "../helpers/createTestAgent"; | ||
|
||
t.test( | ||
"it works", | ||
{ skip: isWindows() ? "path is not the same as path/posix" : false }, | ||
async (t) => { | ||
const agent = createTestAgent(); | ||
|
||
agent.start([new Path()]); | ||
|
||
const { join, resolve, normalize } = require("path/posix"); | ||
|
||
// Path required after path/posix | ||
require("path"); | ||
|
||
const checkForDoubleWrapping = [join, resolve, normalize]; | ||
for (const fn of checkForDoubleWrapping) { | ||
if (isWrapped(fn) && isWrapped(fn.__original)) { | ||
t.fail(`${fn.name} is double wrapped!`); | ||
} | ||
} | ||
} | ||
); | ||
|
||
t.test( | ||
"it works", | ||
{ skip: !isWindows() ? "path is not the same as path/win32" : false }, | ||
async (t) => { | ||
const agent = createTestAgent(); | ||
|
||
agent.start([new Path()]); | ||
|
||
const { join, resolve, normalize } = require("path/win32"); | ||
|
||
// Path required after path/win32 | ||
require("path"); | ||
|
||
const checkForDoubleWrapping = [join, resolve, normalize]; | ||
for (const fn of checkForDoubleWrapping) { | ||
if (isWrapped(fn) && isWrapped(fn.__original)) { | ||
t.fail(`${fn.name} is double wrapped!`); | ||
} | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters