11/// Create a URL from a given path
2- pub fn path_to_url ( path : & std:: path:: Path ) -> Option < String > {
2+ pub fn path_to_url ( path : & std:: path:: Path ) -> String {
33 // Do a best-effort for getting the host in the URL
44 let hostname = if cfg ! ( windows) {
55 // Not supported correctly on windows
@@ -19,28 +19,28 @@ pub fn path_to_url(path: &std::path::Path) -> Option<String> {
1919/// For hyperlink escape codes, the hostname is used to avoid issues with opening a link scoped to
2020/// the computer you've SSH'ed into
2121/// ([reference](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#file-uris-and-the-hostname))
22- pub fn file_to_url ( hostname : Option < & str > , path : & std:: path:: Path ) -> Option < String > {
22+ pub fn file_to_url ( hostname : Option < & str > , path : & std:: path:: Path ) -> String {
2323 let mut url = "file://" . to_owned ( ) ;
2424 if let Some ( hostname) = hostname {
2525 url. push_str ( hostname) ;
2626 }
2727
2828 encode_path ( path, & mut url) ;
2929
30- Some ( url)
30+ url
3131}
3232
3333/// Create a URL from a given hostname and directory path
3434///
3535/// For hyperlink escape codes, the hostname is used to avoid issues with opening a link scoped to
3636/// the computer you've SSH'ed into
3737/// ([reference](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#file-uris-and-the-hostname))
38- pub fn dir_to_url ( hostname : Option < & str > , path : & std:: path:: Path ) -> Option < String > {
39- let mut url = file_to_url ( hostname, path) ? ;
38+ pub fn dir_to_url ( hostname : Option < & str > , path : & std:: path:: Path ) -> String {
39+ let mut url = file_to_url ( hostname, path) ;
4040 if !url. ends_with ( URL_PATH_SEP ) {
4141 url. push_str ( URL_PATH_SEP ) ;
4242 }
43- Some ( url)
43+ url
4444}
4545
4646const URL_PATH_SEP : & str = "/" ;
0 commit comments