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

Failing tests for root URL parsing #1065

Closed

Conversation

Overdrivr
Copy link

This is for ticket #1061

"root": "foo.com/api",
"basePath": "http://foo.com:80/api"
}
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add two https testcase, one with port, one without? Otherwise looks good so far 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @Overdrivr ☝️🙏

Copy link
Author

@Overdrivr Overdrivr Feb 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a few tests with protocols like you requested.

Also added a test to check that if a root url has a trailing backslash (like foo.com/) nocking will still work.

And finally I have added actual checks that node can intercept a request on those root urls. Currently it cannot.

Once those tests pass, I have the feeling nock will be much more enjoyable and easy to use.

@gr2m gr2m force-pushed the i1061-improve-root-url-parsing branch from 5218683 to 5900703 Compare February 23, 2018 16:23
@gr2m
Copy link
Member

gr2m commented Feb 23, 2018

fyi I've rebased your branch on latest master as I got the tests fixed there.

Do you want to take a stab and getting them green?

@Overdrivr
Copy link
Author

I would but I honestly don't have the bandwidth right now for fixing this, especially given that I am not familiar with node-nock source code

@gr2m
Copy link
Member

gr2m commented Feb 26, 2018

neither am I, I figure it out as I go :) no rush we can leave this open

@Overdrivr
Copy link
Author

I fixed the parsing tests, I ended up removing the call to url.parse which was really, really bad at parsing all those specific urls, and rolling out my own solution.

However it seems that it is not sufficient for nock to correctly intercept requests. So I have 14 passing over 27 tests. I am not sure why nock does not intercept requests correctly. Could you have a quick look at the code and let me know if you have an idea why ?

BTW you should avoid rebasing contributors branches for ongoing tickets, because it makes local branches divert from remote, which then forces us to make a local merge if we forget to pull first ;)

@gr2m
Copy link
Member

gr2m commented Mar 6, 2018

BTW you should avoid rebasing contributors branches for ongoing tickets, because it makes local branches divert from remote, which then forces us to make a local merge if we forget to pull first ;)

Yes, I’m very sorry for that, I mixed up PRs, I didn’t meant to rebase yours :(

Could you have a quick look at the code and let me know if you have an idea why ?

Can’t promise when, but I'll try. It will take me some time, too. I’m not so familiar with the code base either I’m afraid, I took on maintainership recently.

this.urlPart = {};

// Extract protocol
var protocolDelim = new RegExp(/\/{2}/);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an advantage with using the RegExp constructor over just var protocolDelim = /\/{2}/?

Also what if someone does sth like nock('http://example.com//foo')? Maybe it would be better to split with /:\/{2}/?

Could you add a comment explaining why we don’t use url.parse() here, maybe reference the pull request?

@stale
Copy link

stale bot commented Sep 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.

@stale stale bot added the stale label Sep 13, 2018
@Overdrivr
Copy link
Author

Sorry about the inactivity. I will have a couple of busy weeks and I'll get a go at it after then

@stale stale bot removed the stale label Sep 14, 2018
@RichardLitt
Copy link
Member

Thanks, @Overdrivr. No worries. :)

@RichardLitt
Copy link
Member

@Overdrivr Any chance you've had some time for this? :)

@Overdrivr
Copy link
Author

Sadly not :(

@RichardLitt
Copy link
Member

I'll pin it. If you have time, it'd be great to see this merged in. :)

paulmelnikow added a commit that referenced this pull request Aug 22, 2019
- Switch to the new URL API which throws errors for most invalid inputs
- Throw errors for URLs with unrecognized schemes
- Add tests for cases that previously had been handled incorrectly

Closes #1061
Supersedes #1065
@paulmelnikow
Copy link
Member

Closing in favor of #1692.

paulmelnikow added a commit that referenced this pull request Sep 6, 2019
- Switch to the new URL API which throws errors for most invalid inputs
- Throw errors for URLs with unrecognized schemes
- Add tests for cases that previously had been handled incorrectly

Closes #1061
Supersedes #1065
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.

None yet

4 participants