MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / encodeFilename

Function encodeFilename

src/common/string.js:54–61  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

52}
53
54export function encodeFilename(name) {
55 // `escape` generated URI has % in it
56 return name.replace(/[-\\/:*?"<>|%\s]/g, (m) => {
57 let code = m.charCodeAt(0).toString(16);
58 if (code.length < 2) code = `0${code}`;
59 return `-${code}`;
60 });
61}
62
63export function decodeFilename(filename) {
64 return filename.replace(/-([0-9a-f]{2})/g, (_m, g) => String.fromCharCode(parseInt(g, 16)));

Callers 1

getNameURIFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected