Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
517 bytes
|
Line | |
---|
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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.