sindresorhus / normalize-url

Normalize a URL
MIT License
840 stars 122 forks source link

make trimming prefix www. optional #2

Closed bkw closed 9 years ago

bkw commented 9 years ago

Blindly assuming the canonical version of www.example.com and example.com was example.com is not necessarily true for all hosts: Sometimes it's just the other way around, and sometimes the zone apex doesn't even resolve.

Can we make this feature optional?

sindresorhus commented 9 years ago

Normalizing the URL isn't about making it the canonical version. That's impossible without doing HTTP requests to figure out. The purpose is to make URLs going to the same place but in different format become identical, so you can more easily compare, sort, and display.

the zone apex doesn't even resolve.

That's a bug in any case. The user usually never type the www so if it doesn't resolve without you're basically blocking a large percentage of users.

So no, not interesting in adding an IMHO useless option :)

glen-84 commented 3 years ago

@sindresorhus Are you still against having a forceWWW option (or similar)?

sindresorhus commented 3 years ago

Yes, because if this is actually a problem, such an option will have the same issue; Not all servers supporting www..

glen-84 commented 3 years ago

I'm not sure what you mean. I know for sure that the server will support www.

I know that you said that "normalizing the URL isn't about making it the canonical version", but normalize just means to make (a text or language) regular and consistent, especially with respect to spelling or style, so I don't see why it cannot also be used for this purpose.

Anyway, I also need the ability to lower-case the URL (excluding the query string), so I may just write my own library for this.

Thanks.