-
Notifications
You must be signed in to change notification settings - Fork 2
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
Getting possible mock file paths can result in a collision #1
Comments
Do you have an proposal on how we should build the paths so we can fix these collisions? |
The problem is that an URI is allowed to contain more characters (see http://tools.ietf.org/html/rfc3986#section-2) than a (cross platform) filename. This makes collisions inevitable. However, we can make the collisions less frequent by separating the GET-params using a different character and by separating the key and value using an obscure character that isn't widely used in URIs. @marijnz0r, @bbrala, do you think something like this would help? Endpoint 1: Endpoint 2: |
I think that should work, though perhaps making the endpoint a directory for parameters would make things even better.
Without parameters
This way parameters and endpoints will not interfere with eachother. |
That's a nice solution! I think it's important to explain it in the readme thoroughly, because it will be more difficult for users to create the correct mock files this way. |
@bbrala using a directory for URIs with GET-params might help, but can also introduce more collisions. api/endpoint?foo api/endpoint/foo @marijnz0r I'm thinking of creating a small JS-helper which converts a given URI to a filepath using the same rules as this client. |
Hmm good point... Technically |
api/endpoint?foo=bar&fizz=buzz I'll create a PR for this! |
Endpoint 1:
api/endpoint?foo_bar_fizz=buzz
Endpoint 2:
api/endpoint?foo=bar&fizz=buzz
Getting possible mock file paths for both the endpoints will result in the same mock file:
api/endpoint.foo-bar-fizz-buzz.mock
I think changes need to be made in the getQueryFromRequst method in the ResponseBuilder.
The text was updated successfully, but these errors were encountered: