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

Support @aspace_backend_url with a path and ensure URI join respects it #19

Merged
merged 1 commit into from
Jun 8, 2016

Conversation

payten
Copy link
Member

@payten payten commented Jun 7, 2016

So.. this might be a bit brute force, but it works!

The first thing we do is now check if aspace_backend_url has a path and store this in aspace_backend_path. Also, we ensure there's a trailing / on the path.

So now we have something like:

aspace_backend_url = 'https://mydomain/my/path'
aspace_backend_path = '/my/path/'

Now in get and post_json, we join the incoming path with the aspace_backend_url and aspace_backend_path. We remove any leading / from the path so it's treated as a relative path:

URI.join(@aspace_backend_url, @aspace_backend_path, path.gsub(/^\//,""))

For example when logging in, this would join 'https://mydomain/my/path' with '/my/path/' and 'users/login'. This results in https://mydomain/my/path/users/login.

When there's no aspace_backend_path (or when it's '/'), this simply becomes the root path and users/login is appended.

@jambun jambun merged commit ddf9e86 into master Jun 8, 2016
@jambun
Copy link
Member

jambun commented Jun 8, 2016

😋

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

Successfully merging this pull request may close these issues.

2 participants