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

Use URL instance in "req.url" #158

Closed
kettanaito opened this issue May 15, 2020 · 0 comments · Fixed by #146
Closed

Use URL instance in "req.url" #158

kettanaito opened this issue May 15, 2020 · 0 comments · Fixed by #146
Assignees
Labels

Comments

@kettanaito
Copy link
Member

kettanaito commented May 15, 2020

This suggests a breaking change.

Is your feature request related to a problem? Please describe.
I suggest to store an intercepted request's URL as a URL instance, as opposed to string.

Benefits

  • URL class is supported in both browser and Node environments;
  • Allows to unify internal implementation in the underlying libraries, leading to fewer URL transformations;
  • Gives more information to the developer, such as req.url.protocol, req.url.port, etc. This information is already available, just not exposed to the developer, which is an experience flaw;

Additional context
There are multiple points of conversion happening, which transform a string representation of a request's URL into a URL instance anyway:

  • node-request-interceptor converts it to URL in order to provide a clean URL in the middleware function;
  • msw@getResponse converts to a URL instance to get a clean URL. With Supports running mocks in Node #146 it will also use that URL instance to resolve a relative URL against the current window.location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant