@ -1,21 +1,10 @@
"use strict" ;
const defaultValue = require ( "default-value" ) ;
const url = require ( "url" ) ;
const ValidationError = require ( "@validatem/error" ) ;
const isString = require ( "@validatem/is-string" ) ;
module . exports = function ( options = { } ) {
let parse = defaultValue ( options . parse , true ) ;
let protocols = options . protocols ;
if ( Array . isArray ( options ) ) { // keep compatibility with <=0.2.0
protocols = options ;
options = { } ;
}
module . exports = function ( protocols ) {
if ( protocols != null && ! Array . isArray ( protocols ) ) {
throw new Error ( ` Permitted protocol list must be an array ` ) ;
}
@ -46,11 +35,7 @@ module.exports = function (options = {}) {
return new ValidationError ( ` Must be a URL with one of the following protocols: ${ validProtocolList } - but got ${ parsedProtocol . toUpperCase ( ) } instead ` , { code : "validatem.is-url.wrong-protocol" } ) ;
} else {
if ( parse ) {
return parsed ;
} else {
return value ;
}
return parsed ;
}
}
] ;