Merge branch 'master' of github.com:lissy93/web-check

This commit is contained in:
Alicia Sykes 2023-08-14 22:44:01 +01:00
commit 645dcf229f
2 changed files with 7 additions and 8 deletions

View File

@ -4,5 +4,5 @@ services:
container_name: Web-Check
image: lissy93/web-check
ports:
- 8888:8888
- 3000:3000
restart: unless-stopped

View File

@ -7,13 +7,12 @@ export type AddressType = 'ipV4' | 'ipV6' | 'url' | 'err' | 'empt';
/* Checks if a given string looks like a URL */
const isUrl = (value: string):boolean => {
const urlPattern = new RegExp(
'^(https?:\\/\\/)?' +
'(?!([0-9]{1,3}\\.){3}[0-9]{1,3})' + // Exclude IP addresses
'(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*' + // Domain name or a subdomain
'([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$', // Second level domain
'i' // Case-insensitive
);
var urlPattern = new RegExp('^(https?:\\/\\/)?'+ // validate protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // validate domain name
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // validate OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // validate port and path
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // validate query string
'(\\#[-a-z\\d_]*)?$','i'); // validate fragment locator
return urlPattern.test(value);
};