This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added the
sourceFilename
property to asset info with original…
… filename (#393)
- Loading branch information
1 parent
381d8bd
commit 654e0d6
Showing
3 changed files
with
86 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function normalizePath(path, stripTrailing) { | ||
if (path === '\\' || path === '/') { | ||
return '/'; | ||
} | ||
|
||
const len = path.length; | ||
|
||
if (len <= 1) { | ||
return path; | ||
} | ||
|
||
// ensure that win32 namespaces has two leading slashes, so that the path is | ||
// handled properly by the win32 version of path.parse() after being normalized | ||
// https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces | ||
let prefix = ''; | ||
|
||
if (len > 4 && path[3] === '\\') { | ||
// eslint-disable-next-line prefer-destructuring | ||
const ch = path[2]; | ||
|
||
if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') { | ||
// eslint-disable-next-line no-param-reassign | ||
path = path.slice(2); | ||
prefix = '//'; | ||
} | ||
} | ||
|
||
const segs = path.split(/[/\\]+/); | ||
|
||
if (stripTrailing !== false && segs[segs.length - 1] === '') { | ||
segs.pop(); | ||
} | ||
|
||
return prefix + segs.join('/'); | ||
} | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export { normalizePath }; |
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