-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* A valid URL (Uniform Resource Locator) in the web typically consists of several components: | ||
* 1. Protocol: This is the type of protocol used for communication, such as "http://" or "https://". | ||
* 2. Domain: This is the unique address of a website, like "example.com" or "google.com". | ||
* 3. Path: This is the specific location or file on the website, such as "/products" or "/about-us.html". | ||
* 4. Query Parameters: These are optional parameters that can be added to a URL to provide additional information to the website, like "?category=books". | ||
* | ||
* | ||
* @param url - the given url string | ||
* @returns true if the URL is valid, false otherwise. | ||
* | ||
* @public | ||
*/ | ||
export function isValidUrl(url: string): boolean { | ||
try { | ||
new URL(url); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} |