Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/path/index.ts>isUrl

A JavaScript extension package for building strong and modern applications.
Latest
function isUrl
Re-export
import { isUrl } from "https://deno.land/x/ayonli_jsext@v0.9.72/path/index.ts";

Checks if the given string is a URL, whether standard or non-standard.

Examples

Example 1

import { isUrl } from "@ayonli/jsext/path";

console.assert(isUrl("http://example.com"));
console.assert(isUrl("https://example.com?foo=bar#baz"));
console.assert(isUrl("ftp://example.com")); // ftp url
console.assert(isUrl("file:///C:/Windows/System32")); // file url
console.assert(isUrl("file://localhost/C:/Windows/System32")); // file url with hostname
console.assert(isUrl("file:///usr/bin"));

Parameters

str: string

Returns

boolean