Check if the given string is a valid HTTP/HTTPS URL.
Usage:
import { isValidHttpUrl } from "mazey";const ret1 = isValidHttpUrl("https://www.example.com");const ret2 = isValidHttpUrl("http://example.com/path/exx/ss");const ret3 = isValidHttpUrl("https://www.example.com/?q=hello&age=24#world");const ret4 = isValidHttpUrl("http://www.example.com/#world?id=9");const ret5 = isValidHttpUrl("//example.com/a/b/c?q=1", { strict: false });const ret6 = isValidHttpUrl("ftp://example.com");console.log(ret1, ret2, ret3, ret4, ret5, ret6); Copy
import { isValidHttpUrl } from "mazey";const ret1 = isValidHttpUrl("https://www.example.com");const ret2 = isValidHttpUrl("http://example.com/path/exx/ss");const ret3 = isValidHttpUrl("https://www.example.com/?q=hello&age=24#world");const ret4 = isValidHttpUrl("http://www.example.com/#world?id=9");const ret5 = isValidHttpUrl("//example.com/a/b/c?q=1", { strict: false });const ret6 = isValidHttpUrl("ftp://example.com");console.log(ret1, ret2, ret3, ret4, ret5, ret6);
Output:
true true true true true false Copy
true true true true true false
If true, the function only matches standard HTTP/HTTPS URLs. Default is true. If false, the function also matches protocol-relative URLs, such as //example.com.
true
false
//example.com
Return true if the given string is a valid HTTP/HTTPS URL.
Check if the given string is a valid HTTP/HTTPS URL.
Usage:
Output: