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

Handle data URIs in store_location_for #4384

Closed
olivierlacan opened this issue Dec 23, 2016 · 3 comments
Closed

Handle data URIs in store_location_for #4384

olivierlacan opened this issue Dec 23, 2016 · 3 comments

Comments

@olivierlacan
Copy link
Contributor

Currently since store_location_for assumes the successfully parsed URI has a non-nil path, it causes the following exception when dealing with data URIs:

store_location_for :user, "data:text/plain;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4="
NoMethodError: undefined method `sub' for nil:NilClass
.../devise-3.5.10/lib/devise/controllers/store_location.rb:38:in `store_location_for'

Would you accept a PR that addresses this?

One potential solution would be to replace:

path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')

With:

[uri.path && path.sub(/\A\/+/, '/'), uri.query].compact.join('?')

Since Data URIs don't contain a path, they'll simply return an empty string as do absolute URIs currently.

@tegon
Copy link
Member

tegon commented Nov 28, 2017

Hi @olivierlacan, thanks for your suggestion.
I'm curious, what's your use case for this?

@olivierlacan
Copy link
Contributor Author

@tegon It's been so long I honestly don't remember but I've managed to survive without this feature so let's close it.

@tegon
Copy link
Member

tegon commented Nov 28, 2017

@olivierlacan Ok, sorry for the late response. If you run into it again, please feel free the open a new issue.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants