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

URL-safe Base64 for use in routes and params #9

Closed
jeremy opened this issue Aug 16, 2014 · 2 comments
Closed

URL-safe Base64 for use in routes and params #9

jeremy opened this issue Aug 16, 2014 · 2 comments
Milestone

Comments

@jeremy
Copy link
Member

jeremy commented Aug 16, 2014

Global IDs can be URI-escaped and embedded in an app's routes and query params, but the percent escaping and needless detail makes a mess of the URL.

Let's provide a nice compact #to_param representation for these cases:

Person.find(1).gid.to_param
# => "Z2lkOi8vYXBwL1BlcnNvbi8x"

(That's just def to_param; Base64.strict_encode64 to_s end)

The locator can try to Base64-decode non-URI arguments:

GlobalID::Locator.locate "Z2lkOi8vYXBwL1BlcnNvbi8x"
# => Person id=1
@jeremy jeremy added this to the 1.0 milestone Aug 16, 2014
@bencrouse
Copy link
Contributor

I added a pull request here #11

@jeremy
Copy link
Member Author

jeremy commented Aug 18, 2014

Implemented by @bencrouse 😁

@jeremy jeremy closed this as completed Aug 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants