- original_url = url (from
a.hreforiframe.src) - effective_url = new URL(original ,parent || homepage)
- If relative, trusted!
- If still error, stop.
- protocol
- Scan?
- Whitelist check (http, https, ftp, ..., ssh)
- So ignore any other (too many apps)
- Default action = allow?
- Scan?
- Domain (Subject)
- Host || pathname
- Add "Search" params?
- Protocol whitlist, like
tg:(telegram) - Not for
https:since they are equally random and ids
- Protocol whitlist, like
Last active
January 28, 2026 23:06
-
-
Save yonixw/fff4c6e10bf7ebd5f725501b53e7ad14 to your computer and use it in GitHub Desktop.
JS URL PARTS
- Domain only (a.b.com, b.com etc, but is it file? like a.pdf)
- punny code (utf8 domains)
- RFC 3986
- https://en.wikipedia.org/wiki/List_of_URI_schemes
- jdbc has
jdbc:sqlserver:andjdbc:mysql:schemas... so multi ":"
- jdbc has
- path params (/a;b=1;c=2/page.php)
| Original URL | Protocol | Host | Hostname | Pathname | Search | Hash |
|---|---|---|---|---|---|---|
http://localhost:8080/ |
http: | localhost:8080 | localhost | / | - | - |
https://abc.com |
https: | abc.com | abc.com | / | - | - |
https://abc.com/ |
https: | abc.com | abc.com | / | - | - |
https://abc.com/somesite |
https: | abc.com | abc.com | /somesite | - | - |
https://abc.com/somesite/x?a=b |
https: | abc.com | abc.com | /somesite/x | ?a=b | - |
https://example.com/ |
https: | example.com | example.com | / | - | - |
mailto:[email protected]?subject=abc.com |
mailto: | [email protected] | ?subject=abc.com | - | ||
mailto:[email protected]?subject=Inquiry&body=Hello, I have a question about... |
mailto: | [email protected] | ?subject=Inquiry&body=Hello,%20I%20have%20a%20question%20about... | - | ||
tel:+15551234567 |
tel: | +15551234567 | - | - | ||
tel:+15551234567,101 |
tel: | +15551234567,101 | - | - | ||
tel:052666666 |
tel: | 052666666 | - | - | ||
tg://resolve?domain=username |
tg: | resolve | resolve | ?domain=username | - | |
tg://msg?text=Hello&to=+15551234567 |
tg: | msg | msg | ?text=Hello&to=+15551234567 | - | |
javascript:void(0); |
javascript: | void(0); | - | - | ||
https://example.com/shop?item=123&color=blue |
https: | example.com | example.com | /shop | ?item=123&color=blue | - |
https://example.com/blog#comments |
https: | example.com | example.com | /blog | - | #comments |
| Original URL | Protocol | Host | Hostname | Pathname | Search | Hash |
|---|---|---|---|---|---|---|
//cdn.example.com/script.js |
Invalid URL | - | - | - | - | |
/contact |
Invalid URL | - | - | - | - | |
./about.html |
Invalid URL | - | - | - | - | |
about.html |
Invalid URL | - | - | - | - | |
../index.html |
Invalid URL | - | - | - | - | |
/a/b/c/d?id=1 |
Invalid URL | - | - | - | - | |
#top |
Invalid URL | - | - | - | - |
const url = new URL(urlStr,"https://parent.com");
| Original URL | Protocol | Host | Hostname | Pathname | Search | Hash |
|---|---|---|---|---|---|---|
//cdn.example.com/script.js |
https: | cdn.example.com | cdn.example.com | /script.js | N/A | N/A |
/contact |
https: | parent.com | parent.com | /contact | N/A | N/A |
./about.html |
https: | parent.com | parent.com | /about.html | N/A | N/A |
about.html |
https: | parent.com | parent.com | /about.html | N/A | N/A |
../index.html |
https: | parent.com | parent.com | /index.html | N/A | N/A |
/a/b/c/d?id=1 |
https: | parent.com | parent.com | /a/b/c/d | ?id=1 | N/A |
#top |
https: | parent.com | parent.com | / | N/A | #top |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # URL | |
| http://localhost:8080/ | |
| https://abc.com | |
| https://abc.com/ | |
| https://abc.com/somesite | |
| https://abc.com/somesite/x?a=b | |
| https://example.com/ | |
| mailto:[email protected]?subject=abc.com | |
| mailto:[email protected]?subject=Inquiry&body=Hello, I have a question about... | |
| # Call Telephone | |
| tel:+15551234567 | |
| tel:+15551234567,101 | |
| tel:052666666 | |
| # Telegram | |
| tg://resolve?domain=username | |
| tg://msg?text=Hello&to=+15551234567 | |
| # Code | |
| javascript:void(0); | |
| # HTTP Examples | |
| https://example.com/shop?item=123&color=blue | |
| https://example.com/blog#comments | |
| //cdn.example.com/script.js | |
| /contact | |
| ./about.html | |
| about.html | |
| ../index.html | |
| /a/b/c/d?id=1 | |
| #top |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const urls = ` | |
| http://localhost:8080/ | |
| https://abc.com | |
| https://abc.com/ | |
| https://abc.com/somesite | |
| https://abc.com/somesite/x?a=b | |
| https://example.com/ | |
| mailto:[email protected]?subject=abc.com | |
| mailto:[email protected]?subject=Inquiry&body=Hello, I have a question about... | |
| tel:+15551234567 | |
| tel:+15551234567,101 | |
| tel:052666666 | |
| tg://resolve?domain=username | |
| tg://msg?text=Hello&to=+15551234567 | |
| javascript:void(0); | |
| https://example.com/shop?item=123&color=blue | |
| https://example.com/blog#comments | |
| //cdn.example.com/script.js | |
| /contact | |
| ./about.html | |
| about.html | |
| ../index.html | |
| /a/b/c/d?id=1 | |
| #top`.split('\n').filter(e=>!!e) | |
| function generateMarkdownTable(urlList) { | |
| // Define the headers for the markdown table | |
| const headers = ["Original URL", "Protocol", "Host", "Hostname", "Pathname", "Search", "Hash"]; | |
| // Create the header and separator rows | |
| let markdown = `| ${headers.join(" | ")} |\n`; | |
| markdown += `| ${headers.map(() => "---").join(" | ")} |\n`; | |
| // Parse each URL and add a row to the table | |
| urlList.forEach(urlStr => { | |
| try { | |
| const url = new URL(urlStr); | |
| const row = [ | |
| `\`${urlStr}\``, | |
| url.protocol, | |
| url.host, | |
| url.hostname, | |
| url.pathname, | |
| url.search || "N/A", | |
| url.hash || "N/A" | |
| ]; | |
| markdown += `| ${row.join(" | ")} |\n`; | |
| } catch (e) { | |
| markdown += `| \`${urlStr}\` | Invalid URL | - | - | - | - |\n`; | |
| } | |
| }); | |
| return markdown; | |
| } | |
| console.log(generateMarkdownTable(urls)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment