c4f5b4241515aa90ea883c9227307b0f10082b3b161a6240234dc9cdf9a7cb8b91c80097e39cb19dc9b7f5c61b93ab48b7f9c2882e02a06b9e0085e85f8749 517 B

12345678910111213141516171819202122232425
  1. 'use strict'
  2. const path = require('path')
  3. // get drive on windows
  4. function getRootPath (p) {
  5. p = path.normalize(path.resolve(p)).split(path.sep)
  6. if (p.length > 0) return p[0]
  7. return null
  8. }
  9. // http://stackoverflow.com/a/62888/10333 contains more accurate
  10. // TODO: expand to include the rest
  11. const INVALID_PATH_CHARS = /[<>:"|?*]/
  12. function invalidWin32Path (p) {
  13. const rp = getRootPath(p)
  14. p = p.replace(rp, '')
  15. return INVALID_PATH_CHARS.test(p)
  16. }
  17. module.exports = {
  18. getRootPath,
  19. invalidWin32Path
  20. }