Fix url parser crash when url is not set
This commit is contained in:
parent
5839fc515f
commit
cb8f0ba3fd
1 changed files with 2 additions and 0 deletions
|
@ -7,10 +7,12 @@ function addProtocol(url, protocol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripProtocol(url){
|
function stripProtocol(url){
|
||||||
|
if(!url) return '';
|
||||||
return url.replace(/(^\w+:|^)\/\//, '');
|
return url.replace(/(^\w+:|^)\/\//, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProtocol(url){
|
function getProtocol(url){
|
||||||
|
if(!url) return '';
|
||||||
const values = url.match(/(^\w+:|^)\/\//);
|
const values = url.match(/(^\w+:|^)\/\//);
|
||||||
|
|
||||||
return values && (values.length > 0) ? values[0] : '';
|
return values && (values.length > 0) ? values[0] : '';
|
||||||
|
|
Loading…
Reference in a new issue