Check a link start with HTTP or HTTPS
How to check a link not start with http:// or https:// below code helps to add and find link does has it or not.
if(pageUrl.indexOf("http://") == 0 || pageUrl.indexOf("https://") == 0 ){
pageUrl = pageUrl;
}else{
pageUrl = "http://" + pageUrl;
}
add a slash and check link end with a slash.
if you also check the link end with slash (/) check the below code. its helps full to add a slash after link end.
var checkLastChar = pageUrl.split('');
var getLastEel = checkLastChar[checkLastChar.length - 1];
if(getLastEel != '/'){
pageUrl = pageUrl + '/';
}
