From 884aaa589cbbe57c19600dbe965c560b52061347 Mon Sep 17 00:00:00 2001 From: Alin Stefan Olaru Date: Tue, 23 Jul 2024 13:59:06 +0200 Subject: [PATCH] fix: regex for url should work a little better now --- .eslintrc | 1 + release.config.js | 2 +- src/link-mobility.service.ts | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4579619..5be6486 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,6 +9,7 @@ ], "rules": { "no-irregular-whitespace": 1, + "no-useless-escape": 0, "@typescript-eslint/no-unused-vars": "error" } } \ No newline at end of file diff --git a/release.config.js b/release.config.js index 162ec08..796d5ae 100644 --- a/release.config.js +++ b/release.config.js @@ -8,7 +8,7 @@ module.exports = { [ '@semantic-release/github', { - 'assets': ['dist/**'] + "successComment": "This PR is included in version ${nextRelease.version} 🎉🎉🎉", } ], '@semantic-release/git' diff --git a/src/link-mobility.service.ts b/src/link-mobility.service.ts index e7dca56..e1f5add 100644 --- a/src/link-mobility.service.ts +++ b/src/link-mobility.service.ts @@ -16,12 +16,13 @@ export class LinkMobilityGateService { constructor(inputs: LinkMobilityGateServiceInputs) { this.username = inputs.username; this.password = inputs.password; - const regexString = - '^(https?|http)://(w{3}.)?[a-zA-Z0-9-]+.[a-zA-Z]{2,}(:[0-9]{2,4})?(/[a-zA-Z0-9-]+)*$'; + + // It should allow for any kind of URL as long as it starts w/ `http` or `https` and it doesn't end in a `/`. + const regexString = '^(https?|http)://(w{3}.)?([a-zA-Z0-9-.]+)(:[0-9]{2,4})?(/[a-zA-Z0-9-]+)*$'; const urlRegex = new RegExp(regexString); if (!urlRegex.test(inputs.url)) { throw new Error( - `Invalid Link Mobility URL. URL must follow the following pattern: ${regexString}` + `Invalid Link Mobility URL. URL must follow the following pattern: ${regexString}. Received: "${inputs.url}"` ); } this.url = `${inputs.url}/gate/partnergate/platform/${inputs.platform}/partner/${inputs.partner}`;