Skip to content

Commit

Permalink
Merge pull request #10255 from jeffin143/fix-10247
Browse files Browse the repository at this point in the history
fix: better handle absolute paths
  • Loading branch information
sokra committed Jan 15, 2020
2 parents 5e9f083 + e826575 commit 627510d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions schemas/ajv.absolutePath.js
Expand Up @@ -25,8 +25,6 @@ module.exports = ajv =>
function callback(data) {
let passes = true;
const isExclamationMarkPresent = data.includes("!");
const isCorrectAbsoluteOrRelativePath =
expected === /^(?:[A-Za-z]:\\|\/)/.test(data);

if (isExclamationMarkPresent) {
callback.errors = [
Expand All @@ -40,8 +38,12 @@ module.exports = ajv =>
];
passes = false;
}

if (!isCorrectAbsoluteOrRelativePath) {
// ?:[A-Za-z]:\\ - Windows absolute path
// \\\\ - Windows network absolute path
// \/ - Unix-like OS absolute path
const isCorrectAbsolutePath =
expected === /^(?:[A-Za-z]:\\|\\\\|\/)/.test(data);
if (!isCorrectAbsolutePath) {
callback.errors = [getErrorFor(expected, data, schema)];
passes = false;
}
Expand Down

0 comments on commit 627510d

Please sign in to comment.