{"type":"rich","version":"1.0","provider_name":"phorkie","provider_url":"https:\/\/p.cweiske.de\/","title":"append a slash to the domain if path is empty?","author_name":"Christian Weiske","cache_age":86400,"width":900,"height":900,"html":"<!-- embedding all files of https:\/\/p.cweiske.de\/140 -->\n<link rel=\"stylesheet\" href=\"https:\/\/p.cweiske.de\/css\/embed.css\"\/>\n<div class=\"phork\" id=\"140\">\n    <div class=\"phork-file\">\n <div class=\"phork-content\">\n  \n<div class=\"document\" id=\"in-an-url-should-i-append-a-slash-to-the-domain\">\n<h1 class=\"title\">In an URL, should I append a slash to the domain?<\/h1>\n\n<div class=\"section\" id=\"rfc-1738-uniform-resource-locators-url\">\n<h1>RFC 1738: Uniform Resource Locators (URL)<\/h1>\n<p>RFC 1738 says the slash is optional:<\/p>\n<pre class=\"literal-block\">\n; HTTP\n\nhttpurl        = &quot;http:\/\/&quot; hostport [ &quot;\/&quot; hpath [ &quot;?&quot; search ]]\nhpath          = hsegment *[ &quot;\/&quot; hsegment ]\n<\/pre>\n<p><a class=\"reference external\" href=\"http:\/\/tools.ietf.org\/html\/rfc1738#page-18\">http:\/\/tools.ietf.org\/html\/rfc1738#page-18<\/a><\/p>\n<\/div>\n<div class=\"section\" id=\"rfc-3986-uniform-resource-identifier-uri-generic-syntax\">\n<h1>RFC 3986: Uniform Resource Identifier (URI): Generic Syntax<\/h1>\n<p>RFC 3986 talks about normalization, and it recommends adding a slash:<\/p>\n<blockquote>\nIn general, a URI that uses the generic syntax for authority with an\nempty path should be normalized to a path of &quot;\/&quot;.<\/blockquote>\n<p><a class=\"reference external\" href=\"http:\/\/tools.ietf.org\/html\/rfc3986#section-6.2.3\">http:\/\/tools.ietf.org\/html\/rfc3986#section-6.2.3<\/a><\/p>\n<\/div>\n<div class=\"section\" id=\"whatwg-url-spec\">\n<h1>WhatWG URL spec<\/h1>\n<p>It also makes the slash after the domain name optional when serializing an URL:<\/p>\n<blockquote>\n<p>An absolute URL must be a scheme, followed by &quot;:&quot;, followed by either a scheme-relative URL [...]<\/p>\n<p>[...]<\/p>\n<p>A scheme-relative URL must be &quot;\/\/&quot;, optionally followed by userinfo and &quot;&#64;&quot;, followed by a host, optionally followed by &quot;:&quot; and a port, optionally followed by an absolute-path-relative URL.<\/p>\n<p>[...]<\/p>\n<p>An absolute-path-relative URL must be &quot;\/&quot;, followed by a path-relative URL that does not start with &quot;\/&quot;.<\/p>\n<\/blockquote>\n<p><a class=\"reference external\" href=\"https:\/\/url.spec.whatwg.org\/#writing\">https:\/\/url.spec.whatwg.org\/#writing<\/a><\/p>\n<\/div>\n<div class=\"section\" id=\"conclusion\">\n<h1>Conclusion<\/h1>\n<p>?<\/p>\n<ul class=\"simple\">\n<li><a class=\"reference external\" href=\"http:\/\/cweiske.de\/\">http:\/\/cweiske.de\/<\/a><\/li>\n<li><a class=\"reference external\" href=\"http:\/\/cweiske.de\">http:\/\/cweiske.de<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n <\/div>\n <div class=\"phork-meta\">\n  <a href=\"https:\/\/p.cweiske.de\/140\/rev-raw\/0f4b7754199ec253218452a326831d0d5c15641e\/README.rst\" style=\"float: right\">view raw source<\/a>\n  <a href=\"https:\/\/p.cweiske.de\/140#README.rst\">README.rst<\/a>\n <\/div>\n<\/div>\n<\/div>\n"}
