imgix-swift
imgix-swift copied to clipboard
feat: allow `buildUrl` to use pre-encoded URLs
Describe the feature
If the buildUrl function builds a Web Proxy URL with a pre-encoded URL, the URL will be double encoded. This returns a 400 error in the Rendering API.
To Reproduce
- Create a Web Proxy Source in imgix
- Use this Swift code (use your own
secureUrlToken):
let signedClient = ImgixClient.init(
host: "imgix-web-proxy-test-source.imgix.net",
secureUrlToken: "EHFQXiZhxP4wA2c4"
)
// This will return a `400` error
signedClient.buildUrl("http%3A%2F%2Fassets.imgix.net%2Fexamples%2Fcat.jpg") // => https://imgix-library-secure-test-source.imgix.net/http%253A%252F%252Fassets.imgix.net%252Fexamples%252Fcat.jpg?s=5751ef13a5ca325fab9c4038b080cd80
Hey @heyitsbryanm, thanks for opening this issue!
This library expects you to give buildUrl() un-encoded paths.
In order to support encoded paths, we'd need to support a flag to remove all URL encoding (which means the URL might not get formatted in a way our render stack can parse) or support the end user passing us a custom encoding function, to replace our encoding behind the scenes.
I can't give you an exact time estimate, but I will now mark this as a feature request and add it to our backlog.
If someone else is interested in this feature, comment or react to this issue to help us prioritize.
Gotcha - changing the description to feature request 👍.