Hello, I want to build a function to remove fragments from URIs, for example, it would convert http://example.com/faqs#one
to http://example.com/faqs
.
List.first(String.split(url, "#"))
does the work, but I think something based on URI
would be better, like:
s = "http://example.com/faqs#one"
u = URI.parse(s)
# %URI{authority: "example.com", fragment: "one", host: "example.com",
# path: "/faqs", port: 80, query: nil, scheme: "http", userinfo: nil}
# Here I need to remove the fragment from the parsed URL, but how to do this?
URI.to_string(u)
# "http://example.com/faqs#one"
How would you do this?
Thanks!