Skip to content

Commit

Permalink
Add hostname validation to URL parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKolarik committed Feb 8, 2025
1 parent 088d5f6 commit c67d312
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/views/components/tags-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@
try {
let { protocol, port, pathname, hostname, search } = new URL(url);

if (!hostname) {
// Just one extra check. The constructor above may throw too.
throw new Error('Invalid URL');
}

this.set('gpMainOpts.type', 'HTTP');
this.set('gpMainOpts.target', tagsArr ? [ ...tagsArr, hostname ].join(delimiter) : hostname);
this.set('gpHttpOpts.protocol', protocol.replace(':', '').toUpperCase());
Expand Down

0 comments on commit c67d312

Please sign in to comment.