sindresorhus/normalize-url

make trimming prefix www. optional

Closed this issue · 4 comments

bkw commented

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?

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 :)

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

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

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.