User.PortfolioURL is not always a valid URL
mjquigley opened this issue · 2 comments
Issue
The Unsplash API can return invalid URLs for the User.PortfolioURL
in the case I ran into the url contained a whitespace character at the end of the url. This causes parsing the entire response to fail.
Potential Fix
Changing User.PortfolioURL
to *string
instead of *Url
should work and handle any invalid URLs there since it's not clear if Unsplash will verify that the url the user enters is valid. Otherwise updating Url.UnmarshalJSON
to trim whitespace before parsing should at least eliminate some of these errors. It could also be a good idea to more gracefully handle errors here so parsing the entire response doesn't fail due to a single malformed URL.
Thank you for reporting the issue.
Would it be possible for you to contribute the fix?
best,
Harry
Sure thing, I submitted a pull request that at least fixes the issue I was running into. I also reached out the Unsplash to see if the URLs should be otherwise valid on their end.