From: matthew@... Date: 2017-01-31T01:02:57+00:00 Subject: [ruby-core:79317] [Ruby trunk Bug#13171] URI::FTP path has a trailing slash when just hostname and scheme provided Issue #13171 has been updated by Matthew Kerwin. Comments about RFC 1738 being "obsolete" notwithstanding, the slash between host/port and url-path is optional when the url-path is empty. Specifically, there is no prohibition on including it. Section 3.1 ("Common Internet Scheme Syntax"): > Some or all of the parts "\:\@", ":\", > ":\", and "/\" may be excluded. and: > url-path >> The rest of the locator consists of data specific to the >> scheme, and is known as the "url-path". It supplies the >> details of how the specified resource can be accessed. Note >> that the "/" between the host (or port) and the url-path is >> NOT part of the url-path. Section 3.2.2. ("FTP url-path"): > The url-path of a FTP URL has the following syntax: > >~~~ > //...//;type= >~~~ So according to the text the slash is purely presentational and has no bearing on the path of the URL. This is reflected in the documentation for [URI::File#path](http://ruby-doc.org/stdlib-2.4.0/libdoc/uri/rdoc/URI/FTP.html#method-i-path) Also please note the specification of how to interpret the path elements *after* that initial slash: https://tools.ietf.org/html/rfc1738#section-3.2.2 Cheers ---------------------------------------- Bug #13171: URI::FTP path has a trailing slash when just hostname and scheme provided https://bugs.ruby-lang.org/issues/13171#change-62727 * Author: Milo Price * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- As with HTTP uris, the trailing slash on a FTP uri should be optional, per RFC 1738 (ftp://ftp.funet.fi/pub/doc/rfc/rfc1738.txt). However, under the current implementation, URI::FTP#to_s always has a trailing slash when only a hostname is provided (i.e., no path): ~~~ ruby URI.parse("http://example.com").to_s => "http://example.com" URI.parse("ftp://example.com").to_s => "ftp://example.com/" ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: