TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What Is the Cardinality of URLs?

3 点作者 Whitespace大约 1 年前
I wonder what the total number of valid URLs including protocol, hostname, path, query parameters, etc. is. A sort of Drake Equation for URLs. This came up when wondering what the cardinality of a single repo on github.com is.<p>I assume it&#x27;s more complex than [number of valid characters]^[browser character limit]. Networking equipment, browsers, archaic protocols, etc. all place limitations&#x2F;requirements on this number.<p>Feel free to simplify it (ex: a single domain) or make it more complex as necessary. For consistency&#x27;s sake let&#x27;s assume I use Chromium stable on 2024-01-01 00:00:01 UTC and the request actually goes out onto the internet (so other hardware touches it)

2 条评论

eesmith大约 1 年前
You&#x27;ve got about 2,000 octets of data, see <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;417142&#x2F;what-is-the-maximum-length-of-a-url-in-different-browsers" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;417142&#x2F;what-is-the-maxim...</a> .<p>That link, while old, has a comment from last year pointing out &#x27;While modern browsers will support longer URLs, search engines do not so the headline figure remains &quot;under 2000 chars&quot;&#x27;.<p>Sure, it will be smaller than that. But &quot;http:a.tv&quot; is a valid start, so you&#x27;ve got nearly 2000 more mostly arbitrary characters. Call it 250 octect values ^ 1990 octets ~ 8E+4771 as a lower bound.<p>The real number is of course much larger than that. The link I gave points other limitations, like Cloudflare&#x27;s URI limit of 32kB at <a href="https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;support&#x2F;troubleshooting&#x2F;http-status-codes&#x2F;4xx-client-error&#x2F;#414-uri-too-longrfc7231httpstoolsietforghtmlrfc7231" rel="nofollow">https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;support&#x2F;troubleshooting&#x2F;ht...</a> .<p>255 ^ (32*1024) ~ 3E+78857<p>I think that&#x27;s a good upper bound.
malfist大约 1 年前
The RFC does not set a limit on the length of urls.<p>So the answer is: ∞