MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / cleanFileName

Function cleanFileName

src/pkg/utils/utils.ts:446–455  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

444}
445
446export function cleanFileName(name: string): string {
447 // https://github.com/Tampermonkey/tampermonkey/issues/2413
448 // https://developer.chrome.com/docs/extensions/reference/api/downloads#type-DownloadOptions
449 // A file path relative to the Downloads directory to contain the downloaded file, possibly containing subdirectories.
450 // Absolute paths, empty paths, and paths containing back-references ".." will cause an error.
451 let n = name;
452 // eslint-disable-next-line no-control-regex
453 n = n.replace(/[\x00-\x1F\\:*?"<>|]+/g, "-");
454 return n.replace(/\.\.+/g, "-").trim();
455}
456
457export const sourceMapTo = (scriptName: string) => {
458 // sandbox 环境中 chrome.runtime 不可用,使用脚本名作为 sourceURL

Callers 2

utils.test.tsFile · 0.90
GM_downloadMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected