PuerkitoBio / purell

tiny Go library to normalize URLs
BSD 3-Clause "New" or "Revised" License
468 stars 59 forks source link

Make normalizing functions public for external consumption #12

Closed VojtechVitek closed 9 years ago

VojtechVitek commented 9 years ago

I'd like to be able to use some of the normalizing functions in external project without the need of purell flags and NormalizeURL*() functions.

Would you be OK with this change?

mna commented 9 years ago

Hi Vojtech,

I understand the idea, but that makes the exposed API to maintain much larger. I'd really prefer to keep it as it currently is, and keep the internal functions implementation details so it can be changed at will (for example, one thing I'd like to do eventually is to do the normalization on the raw bytes or in a buffer instead of on strings, and avoid unnecessary allocations).

Of course, you can still control which normalization gets applied using the flags.

Martin

VojtechVitek commented 9 years ago

The exposed "API" would be just a function name, which by the way pairs 1:1 to (already public) Flag name. You could still change the internal implementation details of all public functions, the func WhateverFunc(u *url.URL) interface doesn't change.

Are you saying that you want to change function names or the interface in the future and you don't want your hands tied?

mna commented 9 years ago

I don't want a larger public API, currently it is just the Normalize* funcs and the flags, I don't want to add a dozen functions to that. As I said, you can still select the normalization to apply with the flags, the overhead is very small, the flag-to-func is a hashtable lookup.