riboseinc / uri_format_validator

Validate URL for Rails
MIT License
3 stars 2 forks source link

Refactor the validator #42

Closed skalee closed 6 years ago

skalee commented 6 years ago

Improve the code style of validator in general.

skalee commented 6 years ago

Hound violations come from the old code.

ronaldtse commented 6 years ago

@skalee this is WIP right? Cause the build is failing...

skalee commented 6 years ago

@ronaldtse Indeed, this pull request isn't merged-in yet because of the CI build failure.

The problem comes from different behaviour of URI(string_to_parse) in Rubinius. Strings with leading and trailing whitespaces, e.g. invalid = " http://google.com ", do not fit the URI grammar. Most Ruby interpreters, including MRI, will raise exception when URI(invalid) is called. However, Rubinius apparently strips these whitespaces and parses the string without error. As a consequence, it is not guaranteed in Rubinius that uri == URI(uri).to_s, and some insignificant at the first glance change in e6ac34166b319b2a23fd4fb9082541f5e65cf8e2 is making Rubinius giving different results.

I am going to improve this pull request today.

skalee commented 6 years ago

Or maybe I'll split this pull request into few on-topic ones?