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

Odd slash behaviour with Request object #208

Open
grug opened this issue Jul 19, 2021 · 1 comment
Open

Odd slash behaviour with Request object #208

grug opened this issue Jul 19, 2021 · 1 comment

Comments

@grug
Copy link

grug commented Jul 19, 2021

Hi there,

This might be a silly question, but I'd like to get to the bottom of it.

When I'm not using this library and I have the following code/test:

    it("should generate the correct request to be sent to the proxy server", () => {
      const request = new Request("https://foo.com");

      expect(request.url).toEqual("https://foo.com");
    });

It passes.

When I start using jest-fetch-mock (set up as per the installation guide) and I run the identical code, I get this failure:

Expected: "https://foo.com"
    Received: "https://foo.com/"

Is there a reason the slash it added at the end? Unfortunately I have a more complex use case that means that this adding of a slash is problematic and isn't simply a case of "just adding the slash to my request object instantiation".

@grug
Copy link
Author

grug commented Jul 20, 2021

I've just seen the readme:

Note: the request "url" is parsed and then printed using the equivalent of new URL(input).href so it may not match exactly with the URL's passed to fetch if they are not fully qualified. For example, passing "http://foo.com" to fetch will result in the request URL being "http://foo.com/" (note the trailing slash).

Is there any way to control this behaviour?

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

No branches or pull requests

1 participant