mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
Merge branch 'chore/url' of https://github.com/zacanger/lemmy into zacanger-chore/url
This commit is contained in:
commit
1f5485fae2
12
ui/src/utils.ts
vendored
12
ui/src/utils.ts
vendored
@ -116,13 +116,11 @@ export function isVideo(url: string) {
|
||||
}
|
||||
|
||||
export function validURL(str: string) {
|
||||
var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
|
||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
|
||||
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
|
||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
|
||||
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
|
||||
'(\\#[-a-z\\d_]*)?$','i'); // fragment locator
|
||||
return !!pattern.test(str);
|
||||
try {
|
||||
return !!new URL(str);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function capitalizeFirstLetter(str: string): string {
|
||||
|
Loading…
Reference in New Issue
Block a user