You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
url + http/https: weird api between these module #8722
url.format will return an object owns pathname rather than path, however http.request and https.request do accept path rather than pathname.
sometimes, we would seem to write our program:
varurlobj=url.format('https://github.com/yorkie');http.request(urlobj,function(res){// actually we get the response from https://github.com/});
path is missing, yeah actually we can add urlobj.path = urlobj.pathname for now, it does work as well, but it's a weird behavior in api level imo.
I'm guessing we should unify these two/three functions definitely, of course backward compatible with url module.
The function mockRequest will be called like http.request or https.request because this function is mocking these 2 official APIs.
Hence that the progress is: calling mockRequest({host: 'github.com', path: '/induty'}) would be equal to url.format({host: 'github.com', path: '/induty'}), and path would be ignored by url.format at that moment. To let example work, we have to add a line: options.pathname = options.path.
Activity
yorkie commentedon Nov 13, 2014
sorry, i mean
url.formatdoesn't acceptpath, the case in real world is https://github.com/yorkie/node-httpmocker/blob/master/index.js#L39.yorkie commentedon Nov 20, 2014
any thoughts from core team?
indutny commentedon Nov 20, 2014
What node.js version are we talking about?
indutny commentedon Nov 20, 2014
Also, could you please paste a complete example of this thing, i.e. the code that works with
httpmodule and doesn't withhttps.yorkie commentedon Nov 20, 2014
From the latest stable docs:
the complete example should be written at https://github.com/yorkie/node-httpmocker/blob/master/index.js#L39, now i copy/paste it here:
The function
mockRequestwill be called likehttp.requestorhttps.requestbecause this function is mocking these 2 official APIs.Hence that the progress is: calling
mockRequest({host: 'github.com', path: '/induty'})would be equal tourl.format({host: 'github.com', path: '/induty'}), andpathwould be ignored byurl.formatat that moment. To let example work, we have to add a line:options.pathname = options.path.To reproduce this on
v0.10.33:yorkie commentedon Nov 20, 2014
and this actually is not related
httporhttps, but never mind, it's not a bug just wanna get thoughts from core team 🌸indutny commentedon Nov 20, 2014
Oh, I see. It doesn't look like there could be a reason why it should not support
pathas well aspathname. Mind submitting a PR with test? ;)yorkie commentedon Nov 20, 2014
bingo, then would do that later 🍒
url: support `path` for url.format
chrisdickinson commentedon Dec 2, 2014
Fixed in d312b6d.
url: support `path` for url.format