check link for string code example
Example 1: check if url contains string
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (window.location.href.indexOf("franky") > -1) {
alert("your url contains the name franky");
}
});
</script>
Example 2: javascript url check
const isAbsoluteUrl = url => /^[a-z][a-z0-9+.-]*:/.test(url);
isAbsoluteUrl('https://1loc.dev');
isAbsoluteUrl('https://1loc.dev/foo/bar');
isAbsoluteUrl('1loc.dev');
isAbsoluteUrl('//1loc.dev');