Skip to content

Commit ce53ac8

Browse files
authored
Merge branch 'postmanlabs:develop' into fix/issue#660
2 parents 9d631f1 + 95cc99c commit ce53ac8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/schemaUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ module.exports = {
371371
}
372372
return '{' + p1 + '}';
373373
};
374-
return url.replace(/(\{[^\/\{\}]+\})/g, replacer);
374+
return _.isString(url) ? url.replace(/(\{[^\/\{\}]+\})/g, replacer) : '';
375375
},
376376

377377
/**

test/unit/util.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,13 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
25772577
});
25782578

25792579
describe('fixPathVariablesInUrl function', function() {
2580+
it('should be able to handle incorrect urls', function(done) {
2581+
expect(SchemaUtils.fixPathVariablesInUrl({})).to.equal('');
2582+
expect(SchemaUtils.fixPathVariablesInUrl(null)).to.equal('');
2583+
expect(SchemaUtils.fixPathVariablesInUrl(undefined)).to.equal('');
2584+
done();
2585+
});
2586+
25802587
it('should convert a url with scheme and path variables', function(done) {
25812588
var convertedUrl = SchemaUtils.fixPathVariablesInUrl('{scheme}://developer.uspto.gov/{path0}/segment/{path1}');
25822589
expect(convertedUrl).to.equal('{{scheme}}://developer.uspto.gov/{{path0}}/segment/{{path1}}');

0 commit comments

Comments
 (0)