Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

win32.js 517B

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. }