Skip to content

Commit d8c74b6

Browse files
committed
fix: better handle absolute paths
1 parent 45ecebc commit d8c74b6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

schemas/ajv.absolutePath.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ module.exports = ajv =>
2525
function callback(data) {
2626
let passes = true;
2727
const isExclamationMarkPresent = data.includes("!");
28-
const isCorrectAbsoluteOrRelativePath =
29-
expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
3028

3129
if (isExclamationMarkPresent) {
3230
callback.errors = [
@@ -40,8 +38,12 @@ module.exports = ajv =>
4038
];
4139
passes = false;
4240
}
43-
44-
if (!isCorrectAbsoluteOrRelativePath) {
41+
// ?:[A-Za-z]:\\ - Windows absolute path
42+
// \\\\ - Windows network absolute path
43+
// \/ - Unix-like OS absolute path
44+
const isCorrectAbsolutePath =
45+
expected === /^(?:[A-Za-z]:(\\|\/)|\\\\|\/)/.test(data);
46+
if (!isCorrectAbsolutePath) {
4547
callback.errors = [getErrorFor(expected, data, schema)];
4648
passes = false;
4749
}

0 commit comments

Comments
 (0)