| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 128e1e2 commit e554ce7
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,11 +97,15 @@ function parseHostname(host) { | |||
| 97 | 97 | if (!host) { | |
| 98 | 98 | return null; | |
| 99 | 99 | } | |
| 100 | + // If the host doesn't have a proper protocol, add one to make URL parsing work | ||
| 101 | + const hasValidProtocol = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(host); | ||
| 102 | + | ||
| 103 | + if (!hasValidProtocol) { | ||
| 104 | + return host; | ||
| 105 | + } | ||
| 100 | 106 | ||
| 101 | 107 | try { | |
| 102 | - // If the host doesn't have a protocol, add one to make URL parsing work | ||
| 103 | - const urlString = host.includes("://") ? host : `http://${host}`; | ||
| 104 | - const url = new URL(urlString); | ||
| 108 | + const url = new URL(host); | ||
| 105 | 109 | return url.hostname; | |
| 106 | 110 | } catch (err) { | |
| 107 | 111 | // If URL parsing fails, check if the host is already a hostname (no protocol, no path) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments