Lenient URL scanner with parentheses detection
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
URLScanner.xcodeproj Small changes to the project settings Jul 4, 2011
NSString+URLScanning.m Fixed the possible crash by dereferencing null pointer Apr 3, 2012


URLScanner - Lenient URL scanner with parentheses detection

What is it?

It's a category for NSString to support URL scanning. It parses URLs in lenient manner, while making sure that parentheses in a string are recognized appropriately.

Example 1:

String: [https://テスト).com]
URL: https://テスト).com

The URL above is grouped by parentheses, and the actual URL contains Japanese characters and a closing bracket (U+FF09).

Example 2:

String: (http://en.wikipedia.org/wiki/Perl_(disambiguation))
URL: http://en.wikipedia.org/wiki/Perl_(disambiguation)

The second example shows an example of an URL that contains parentheses inside an URL, that is not escaped properly.

This URL Scanner can deal with cases like above, which is difficult to handle with just regular expressions.


The scanner is very lenient, because it is designed to parse Tweets in my Twitter client YoruFukurou, which is expected to handle URLs pasted from a variety of sources (e.g. from Safari address bar, which does not percent escape the URL).