Fix url parser crash when url is not set

This commit is contained in:
Letícia Camara 2018-10-13 02:04:46 -03:00
parent 5839fc515f
commit cb8f0ba3fd

View file

@ -7,10 +7,12 @@ function addProtocol(url, protocol) {
}
function stripProtocol(url){
if(!url) return '';
return url.replace(/(^\w+:|^)\/\//, '');
}
function getProtocol(url){
if(!url) return '';
const values = url.match(/(^\w+:|^)\/\//);
return values && (values.length > 0) ? values[0] : '';