Skip to content

Commit

Permalink
Fix #191
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Jan 25, 2024
1 parent 5bc082d commit 13efc6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/tools/validation-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function validateUnsignedFloat(value: string): boolean {
export function validateUrl(url: string): boolean {

const urlRegex =
/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/;
/^https?:\/\/(localhost|(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6})([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/;

const result = url.match(urlRegex);
return result !== null && result[0] === url;
Expand Down
3 changes: 3 additions & 0 deletions core/test/tools/validation-util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ describe('ValidationUril', () => {

expect(validateUrl('http://www.example.de')).toBe(true);
expect(validateUrl('https://www.example.de')).toBe(true);
expect(validateUrl('http://localhost:4000')).toBe(true);
expect(validateUrl('http://example.de')).toBe(true);
expect(validateUrl('http://abc')).toBe(false);
expect(validateUrl('www.example.de')).toBe(false);
expect(validateUrl('abc')).toBe(false);
});
Expand Down

0 comments on commit 13efc6f

Please sign in to comment.