Parens must be balanced to be excluded from urls

Prevents an ending paren in url from being excluded from the url unless the entire url is wrapped in parens.
Shouldn't the last equality be testing against the opposing parenthesis/bracket?