Skip to content

Commit

Permalink
Merge branch 'master' into esm-cli-plugin-support
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 12, 2021
2 parents 9c43b8e + 2810269 commit 9c5f2eb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/utils/sanitizeFileName.ts
@@ -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, '_');
}
2 changes: 1 addition & 1 deletion test/chunking-form/samples/sanitize-chunk-names/_config.js
Expand Up @@ -5,7 +5,7 @@ module.exports = {
plugins: [
{
options(options) {
options.input = ['\0virtual:entry-1', '\0virtual:entry-2'];
options.input = ['\0virtual:entry-1', '\0virtual:entry-2', 'another-[slug]-#result'];
return options;
},
resolveId(id) {
Expand Down
@@ -0,0 +1,7 @@
define((function () { 'use strict';

var another__slug___result = "another-[slug]-#result";

return another__slug___result;

}));
@@ -0,0 +1,5 @@
'use strict';

var another__slug___result = "another-[slug]-#result";

module.exports = another__slug___result;
@@ -0,0 +1,3 @@
var another__slug___result = "another-[slug]-#result";

export { another__slug___result as default };
@@ -0,0 +1,10 @@
System.register([], (function (exports) {
'use strict';
return {
execute: (function () {

var another__slug___result = exports('default', "another-[slug]-#result");

})
};
}));

0 comments on commit 9c5f2eb

Please sign in to comment.