Created
November 25, 2010 10:02
-
-
Save chirantan/715149 to your computer and use it in GitHub Desktop.
How to override Rails auto_link helper regular expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionView::Helpers::TextHelper::AUTO_LINK_RE = %r{ | |
( # leading text | |
<\w+.*?>| # leading HTML tag, or | |
[^=!:'"/]| # leading punctuation, or | |
^ # beginning of line | |
) | |
( | |
(?:https?://)| # protocol spec, or | |
(?:www\.)| # www.* | |
) | |
( | |
[-\w]+ # subdomain or domain | |
(?:\.[-\w]+)* # remaining subdomains or domain | |
(?::\d+)? # port | |
(?:/(?:[~\w\+@%=\(\)-]|(?:[,.;:'][^\s$]))*)* # path | |
(?:\?[\w\+@%&=.;:/-]+)? # query string | |
(?:\#[\w\-]*)? # trailing anchor | |
) | |
([[:punct:]]|<|$|) # trailing text | |
| | |
}x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment