hasprotocol

Returns true/false if string starts protocol such as http://

Usage no npm install needed!

<script type="module">
  import hasprotocol from 'https://cdn.skypack.dev/hasprotocol';
</script>

README

hasprotocol

Returns true/false if string starts with a protocol such as http

hasProtocol('http://') //true
hasProtocol('http://hello') //true
hasProtocol('helloworldhttp://hello') //false


hasProtocol('https://') //true
hasProtocol('https://hello') //true
hasProtocol('helloworldhttps://hello') //false


hasProtocol('localhost://') //true
hasProtocol('localhost://hello') //true
hasProtocol('helloworldlocalhost://hello') //false


hasProtocol('file:///') //true
hasProtocol('file:///') //true
hasProtocol('helloworldfile:///') //false