Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to parse URLs #3849

Closed
jetwash opened this issue Aug 30, 2017 · 2 comments · Fixed by #3900
Closed

Function to parse URLs #3849

jetwash opened this issue Aug 30, 2017 · 2 comments · Fixed by #3900

Comments

@jetwash
Copy link

jetwash commented Aug 30, 2017

I'd like to be able to extract a domain name from a URL so I can tell people where they are going. I'm using a regex now, but obviously it's a bit naïve. It would be nice to have a function in Hugo to do this.

I figure it would probably make more sense to return a map with entries like scheme, host, port, path, query, etc., instead of restricting it to the domain. Basically, what Parse in net/url does.

It would also be very useful if it could include the effective TLD+1 in the return value, using the public suffix list. There is already a go package to make it easy.

@bep
Copy link
Member

bep commented Aug 31, 2017

To be clear: We can add net.Parse (=> urls.Parse), but we're not doing some TLD+1.

moorereason added a commit to moorereason/hugo that referenced this issue Sep 24, 2017
Add a urls.Parse template function that front-ends url.Parse from the Go
stdlib.

Fixes gohugoio#3849
@bep bep closed this as completed in #3900 Sep 24, 2017
bep pushed a commit that referenced this issue Sep 24, 2017
Add a urls.Parse template function that front-ends url.Parse from the Go
stdlib.

Fixes #3849
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants