-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Romuald Brillout <[email protected]>
- Loading branch information
Showing
7 changed files
with
35 additions
and
15 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export { pathJoin } | ||
export { pathIsAbsolute } | ||
|
||
// Simple shim for `import * from "node:path"` used by the server runtime. | ||
// Robust alternative: https://github.com/unjs/pathe | ||
|
||
import { assert } from './assert.js' | ||
|
||
function pathJoin(path1: string, path2: string): string { | ||
assert(!path1.includes('\\')) | ||
assert(!path2.includes('\\')) | ||
let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/') | ||
if (path1.startsWith('/')) joined = '/' + joined | ||
return joined | ||
} | ||
|
||
// https://github.com/unjs/pathe/blob/1eadc66c0fb3b2916cbcc1c73370bf4b824985ff/src/path.ts#L14 | ||
const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/ | ||
function pathIsAbsolute(filePath: string) { | ||
return IS_ABSOLUTE_RE.test(filePath) | ||
} |