-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from Nisarg155/master
added is-url
- Loading branch information
Showing
5 changed files
with
283 additions
and
213 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
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,20 @@ | ||
|
||
# is-url | ||
|
||
Check whether a string is a URL. | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install is-url | ||
``` | ||
|
||
## API | ||
|
||
### `isUrl(string)` | ||
|
||
Returns a Boolean indicating whether `string` is a URL. | ||
|
||
## License | ||
|
||
MIT |
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,18 @@ | ||
const isUrl = require('is-url'); | ||
|
||
// Test URLs | ||
const validUrl = 'https://www.example.com'; | ||
const invalidUrl = 'not a valid url'; | ||
|
||
// Check if a URL is valid | ||
if (isUrl(validUrl)) { | ||
console.log(`${validUrl} is a valid URL.`); | ||
} else { | ||
console.log(`${validUrl} is not a valid URL.`); | ||
} | ||
|
||
if (isUrl(invalidUrl)) { | ||
console.log(`${invalidUrl} is a valid URL.`); | ||
} else { | ||
console.log(`${invalidUrl} is not a valid URL.`); | ||
} |
Oops, something went wrong.