Merge pull request #275 from postmanlabs/feature/fix-root-path-mismatch

Fixed issue where root path was not matched during validation.
This commit is contained in:
Vishal Shingala
2020-08-07 16:33:37 +05:30
committed by GitHub
2 changed files with 21 additions and 0 deletions

View File

@@ -3616,6 +3616,15 @@ module.exports = {
} }
}); });
// handle root path '/'
if (postmanPath === '/' && schemaPath === '/') {
anyMatchFound = true;
maxScoreFound = 1; // assign max possible score
matchedPathVars = []; // no path variables present
fixedMatchedSegments = 0;
variableMatchedSegments = 0;
}
if (anyMatchFound) { if (anyMatchFound) {
return { return {
match: true, match: true,

View File

@@ -2136,3 +2136,15 @@ describe('convertToPmQueryArray function', function() {
expect(result[1]).to.equal('variable3=456%20456'); expect(result[1]).to.equal('variable3=456%20456');
}); });
}); });
describe('getPostmanUrlSchemaMatchScore function', function() {
it('Should correctly match root level path with matching request endpoint', function () {
let schemaPath = '/',
pmPath = '/',
endpointMatchScore = SchemaUtils.getPostmanUrlSchemaMatchScore(schemaPath, pmPath, {});
// root level paths should match with max score
expect(endpointMatchScore.match).to.eql(true);
expect(endpointMatchScore.score).to.eql(1);
});
});