Skip to content

isHttpUrl()

Returns true if url starts with https:// or http:// (case-sensitive, as in String#startsWith). Does not validate that the rest is a well-formed URL — only the scheme prefix. blob:, data:, and relative paths return false.

Examples:

ts
isHttpUrl('https://example.com/path'); // true
isHttpUrl('http://localhost:3000'); // true
ts
isHttpUrl('//cdn.example.com'); // false — no explicit http(s) prefix
isHttpUrl('/assets/logo.png'); // false — relative path

Released under the MIT License.