Newer
Older
CVSS_3.0_GUI / node_modules / nwjs-builder-phoenix / node_modules / fs-extra / lib / mkdirs / win32.js
root on 7 May 2019 517 bytes Initial commit
  1. 'use strict'
  2.  
  3. const path = require('path')
  4.  
  5. // get drive on windows
  6. function getRootPath (p) {
  7. p = path.normalize(path.resolve(p)).split(path.sep)
  8. if (p.length > 0) return p[0]
  9. return null
  10. }
  11.  
  12. // http://stackoverflow.com/a/62888/10333 contains more accurate
  13. // TODO: expand to include the rest
  14. const INVALID_PATH_CHARS = /[<>:"|?*]/
  15.  
  16. function invalidWin32Path (p) {
  17. const rp = getRootPath(p)
  18. p = p.replace(rp, '')
  19. return INVALID_PATH_CHARS.test(p)
  20. }
  21.  
  22. module.exports = {
  23. getRootPath,
  24. invalidWin32Path
  25. }
Buy Me A Coffee