Skip to content

isUrl

Returns true if the given data is in the correct URL format. If withProtocol is true, it is automatically appended to the URL when the protocol does not exist. If strict is true, URLs without commas (.) return false.

Parameters

  • url::string
  • withProtocol::boolean || false
    Named
  • strict::boolean || false
    Named

Returns

boolean

Examples

javascript
isUrl('google.com'); // Returns false
isUrl('google.com', true); // Returns true
isUrl('https://google.com'); // Returns true
dart
isUrl('google.com'); // Returns false
isUrl('google.com', withProtocol: true); // Returns true
isUrl('https://google.com'); // Returns true

Released under the MIT License