cvent / json-schema-deref-sync

Synchronous json schema dereference utility
http://bojand.github.io/json-schema-deref-sync
MIT License
35 stars 24 forks source link

File references are not considered of type 'file' #23

Closed devonhumes closed 5 years ago

devonhumes commented 5 years ago

1) What version of the module is the issue happening on? Does the issue happen on latest version?

0.10.0

2) What platform and Node.js version? (For example Node.js 0.12 on Mac OS X)

10.15.3

3) Sample source code or steps to reproduce

References that use the file: prefix are not correctly marked as files. This is due to the boolean check at https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/utils.js#L36.

This check performs this boolean (validUrl.isUri(val) && val.indexOf('file:') === '0'). However, the value of val.indexOf('file:') is a number not a string. When using exactly equals (===) no type conversion will occur. This will make the test fail and incorrectly mark this as not a file.

Example: file:path/file.json#/parent/child