{"action":"created","issue":{"url":"https://api.github.com/repos/servo/rust-url/issues/24","repository_url":"https://api.github.com/repos/servo/rust-url","labels_url":"https://api.github.com/repos/servo/rust-url/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/servo/rust-url/issues/24/comments","events_url":"https://api.github.com/repos/servo/rust-url/issues/24/events","html_url":"https://github.com/servo/rust-url/issues/24","id":41833858,"number":24,"title":"to_file_path() on localhost returns Path::new(\"/\")","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-09-03T16:09:41Z","updated_at":"2016-04-21T07:23:13Z","closed_at":null,"body":"For example, this program will print `/`\r\n\r\n```rust\r\nextern crate url;                                                 \r\n                                                                  \r\nuse url::Url;                                                     \r\n                                                                  \r\nfn main() {                                                       \r\n    let url = Url::parse(\"http://postgres@localhost/\").unwrap();  \r\n    println!(\"{}\", url.to_file_path::<Path>().unwrap().display());\r\n}                                                                 \r\n```\r\n\r\nIs this expected? If so, is there a way to differentiate paths with hosts from those with paths? It also looks like [this may be relevant](https://github.com/servo/rust-url/blob/d894135cac4e0085f41ba3a816240b792f9e6154/src/lib.rs#L823)"},"comment":{"url":"https://api.github.com/repos/servo/rust-url/issues/comments/212782839","html_url":"https://github.com/servo/rust-url/issues/24#issuecomment-212782839","issue_url":"https://api.github.com/repos/servo/rust-url/issues/24","id":212782839,"user":{"login":"SimonSapin","id":291359,"avatar_url":"https://avatars.githubusercontent.com/u/291359?v=3","gravatar_id":"","url":"https://api.github.com/users/SimonSapin","html_url":"https://github.com/SimonSapin","followers_url":"https://api.github.com/users/SimonSapin/followers","following_url":"https://api.github.com/users/SimonSapin/following{/other_user}","gists_url":"https://api.github.com/users/SimonSapin/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonSapin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonSapin/subscriptions","organizations_url":"https://api.github.com/users/SimonSapin/orgs","repos_url":"https://api.github.com/users/SimonSapin/repos","events_url":"https://api.github.com/users/SimonSapin/events{/privacy}","received_events_url":"https://api.github.com/users/SimonSapin/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T07:23:13Z","updated_at":"2016-04-21T07:23:13Z","body":"`to_file_path` doesn’t have a type parameter anymore, but other than that this behavior hasn’t changed. Still, it matches the doc-comment. What outcome would you rather have?\r\n\r\n> Assuming the URL is in the `file` scheme or similar, convert its path to an absolute `std::path::Path`.\r\n>\r\n> **Note:** This does not actually check the URL’s `scheme`, and may give nonsensical results for other schemes. It is the user’s responsibility to check the URL’s scheme before calling this.\r\n>\r\n> ```\r\n> # use url::Url;\r\n> # let url = Url::parse(\"file:///etc/passwd\").unwrap();\r\n> let path = url.to_file_path();\r\n> ```\r\n>\r\n> Returns `Err` if the host is neither empty nor `\"localhost\"`, or if `Path::new_opt()` returns `None`. (That is, if the percent-decoded path contains a NUL byte or, for a Windows path, is not UTF-8.)\r\n"}}