diff --git a/package.json b/package.json index 337241b..aef7ba1 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "webpack-merge": "^5.8.0" }, "scripts": { + "preinstall": "npx only-allow yarn", "watch": "webpack --watch --config webpack.dev.js", "start": "webpack-dev-server --mode development --config webpack.dev.js", "build:dev": "webpack --mode development --config webpack.dev.js", diff --git a/src/utils.ts b/src/utils.ts index 33caec7..b37ddeb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,7 +2,7 @@ export function urlPath(path: string): string { path = path.trim(); //regex to check if is an absolute url (with *a* protocol) or a valid URI - const urlRegex = /^([a-z0-9]+:\/\/|www.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i; + const urlRegex = /^(https?:\/\/)?([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*|localhost)(:\d{1,5})?(\/[^\s]*)?$/i if (path.match(urlRegex)) { return path;