Advertisement
Guest User

Untitled

a guest
May 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. /**
  2. * 将路径编码为 Windows 合法路径。
  3. * @param {string} path 路径字符串。
  4. * @param {string} replaced 不合法字符的替换字符。
  5. */
  6. function EncodeWindowsPath(path, replaced = ' ') {
  7. const reserved = ['<', ':', '"', '/', '\\', '|', '?', '*'];
  8. let encodedPath = '';
  9.  
  10. for (let char of path) {
  11. encodedPath += char in reserved ? replaced : char;
  12. }
  13.  
  14. return encodedPath;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement