hoxy icon indicating copy to clipboard operation
hoxy copied to clipboard

Rename "url" APIs to "path".

Open sholladay opened this issue 10 years ago • 6 comments
trafficstars

Having url and fullUrl is an odd concept to me. It seems like a wart in Hoxy's otherwise excellent semantics. I find myself explaining it in code comments.

Would you be open to renaming the usages of "url" to "path" where that is what it really means?

As a stretch goal, "fullUrl" could then become "url".

sholladay avatar Nov 05 '15 18:11 sholladay

Is path really a better term since it contains the protocol and domain as well? On 5 Nov 2015 19:35, "Seth Holladay" [email protected] wrote:

Having url http://greim.github.io/hoxy/#request-url and fullUrl http://greim.github.io/hoxy/#request-fullUrl is an odd concept to me. It seems like a wart in Hoxy's otherwise excellent semantics. I find myself explaining it in code comments.

Would you be open to renaming the usages of "url" to "path" where that is what it really means?

As a stretch goal, "fullUrl" could then become "url".

— Reply to this email directly or view it on GitHub https://github.com/greim/hoxy/issues/66.

editedredx avatar Nov 05 '15 18:11 editedredx

Aha! See, it is confusing people. No, @editedredx request.url, the intercept 'url' option, etc. are all paths. They do not include the protocol or host. You are thinking of request.fullUrl() and friends.

sholladay avatar Nov 05 '15 20:11 sholladay

req.url is root-relative because that's how node http servers (and express) do it. At least that was my thinking at the time :) Maybe when the next major version comes out we could consider renaming these, since it would be a breaking change.

greim avatar Nov 05 '15 20:11 greim

That is fair. Maybe I am barking up the wrong tree. Express gets that from Node's own http module, which has a similar weirdness. When making an http.request() as a client, it calls this path, but when receiving a request message as a server, it calls this url. I am strongly in favor of removing the dissonance between url and fullUrl, in one form or another. It is easy and reasonable to be surprised that url is not "full". That's really the problem I'm trying to solve.

sholladay avatar Nov 05 '15 22:11 sholladay

Short of breaking changes, we could alias url => path and refer to that instead in the docs if you think that would help. I'd accept a PR for that.

greim avatar Nov 06 '15 15:11 greim

:+1: I'll make a PR sometime this coming week.

sholladay avatar Nov 06 '15 19:11 sholladay