News for hackers. Stuff that matters.
Re:In search of the perfect URL validation regex by mathias on Monday June 23, 2014 @03:11AM (#7930620)
My exact use case was the following: the user clicks a bookmarklet that passes the current URL in the browser as a query string parameter to a URL shortener script. The validation is then performed before the URL is shortened.

In that scenario, and with the given requirements, I can’t think of a case where the validation fails. There’s no need to worry about protocol-relative URLs, etc.

(Keep in mind that this page is 4 years old — I very well may have missed something.)

> If you really want your URL shortener to reject bad URLs, then you need to actually test fetching each URL (and even then...)

I disagree. http://example.com/ might experience downtime at some point in time, but that doesn’t mean it’s suddenly an invalid URL.

> As an aside, I'd instantly fail any library that validates against a list of known TLDs. That was a bad idea when people were doing it a decade ago. It's completely impractical now.

Agreed.

Re:In search of the perfect URL validation regex by eli on Monday June 23, 2014 @07:44AM (#7931358)
I still don't quite follow the purpose of the validation. Is it against malicious use? In normal use, I would think that pretty much any URL that's good enough for the browser sending it would be good enough for the link shortener.
Re:In search of the perfect URL validation regex by mathias on Monday June 23, 2014 @09:11AM (#7931709)
But then you might end up shortening things like `about:blank` by accident.