Skip to content

Commit

Permalink
fix: regex for url should work a little better now
Browse files Browse the repository at this point in the history
  • Loading branch information
xShteff committed Jul 23, 2024
1 parent a0a146e commit 884aaa5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"rules": {
"no-irregular-whitespace": 1,
"no-useless-escape": 0,
"@typescript-eslint/no-unused-vars": "error"
}
}
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
[
'@semantic-release/github',
{
'assets': ['dist/**']
"successComment": "This PR is included in version ${nextRelease.version} 🎉🎉🎉",
}
],
'@semantic-release/git'
Expand Down
7 changes: 4 additions & 3 deletions src/link-mobility.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down

0 comments on commit 884aaa5

Please sign in to comment.