path.Join gives inaccurate results when there is https or http prefix

When I want to use join a path like “” and “blob/master”, the result is like “https:/”.

I guess path.Join just removes repeated slashes? So it will get a wrong result when a prefix like https:// or http:// exists. And can we adapt it so that it can behave well when those prefix exists? Or I just used the wrong method?

A path is a local path, not an URL. That’s probably the error in thought. I would do something along the lines of `printf ("%s%s" .Site.baseURL “/blob/master”)

Ok, got it. Thank you so much!

That said, I would recommend using the built-in funcs for this, e.g.:

{{  “/blob/master” | absURL }}
{{  “/blob/master” | relURL }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.