Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into esm-cli-plugin-support
- Loading branch information
Showing
6 changed files
with
31 additions
and
2 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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
// https://datatracker.ietf.org/doc/html/rfc2396 | ||
// eslint-disable-next-line no-control-regex | ||
const INVALID_CHAR_RE = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; | ||
|
||
export function sanitizeFileName(name: string): string { | ||
const match = /^[a-z]:/i.exec(name); | ||
const driveLetter = match ? match[0] : ''; | ||
|
||
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo) | ||
// Otherwise, avoid them because they can refer to NTFS alternate data streams. | ||
return driveLetter + name.substr(driveLetter.length).replace(/[\0?*:]/g, '_'); | ||
return driveLetter + name.substr(driveLetter.length).replace(INVALID_CHAR_RE, '_'); | ||
} |
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
7 changes: 7 additions & 0 deletions
7
test/chunking-form/samples/sanitize-chunk-names/_expected/amd/another-_slug_-_result.js
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,7 @@ | ||
define((function () { 'use strict'; | ||
|
||
var another__slug___result = "another-[slug]-#result"; | ||
|
||
return another__slug___result; | ||
|
||
})); |
5 changes: 5 additions & 0 deletions
5
test/chunking-form/samples/sanitize-chunk-names/_expected/cjs/another-_slug_-_result.js
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,5 @@ | ||
'use strict'; | ||
|
||
var another__slug___result = "another-[slug]-#result"; | ||
|
||
module.exports = another__slug___result; |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/sanitize-chunk-names/_expected/es/another-_slug_-_result.js
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 @@ | ||
var another__slug___result = "another-[slug]-#result"; | ||
|
||
export { another__slug___result as default }; |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/sanitize-chunk-names/_expected/system/another-_slug_-_result.js
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,10 @@ | ||
System.register([], (function (exports) { | ||
'use strict'; | ||
return { | ||
execute: (function () { | ||
|
||
var another__slug___result = exports('default', "another-[slug]-#result"); | ||
|
||
}) | ||
}; | ||
})); |