diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2013-03-04 01:11:51 -0600 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2013-03-04 01:11:51 -0600 |
commit | 0f7b5fce63b58fc05bc8dab114668ccafb82b8ff (patch) | |
tree | 8f743297a821a2ad9daaf6b1dc5129644150dc44 | |
parent | ebe504695f6027dde6914a5eed4aa6d243b911f9 (diff) | |
download | pathery-0f7b5fce63b58fc05bc8dab114668ccafb82b8ff.tar.xz |
BUGFIX: Multiple hashes (#) in a line break url creation in chat
-rw-r--r-- | pages/chat.php | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/pages/chat.php b/pages/chat.php index 41b07fb..27122d8 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -147,15 +147,13 @@ function chatReplaceAndEncode(chat) { chat = chat.replace(/\*\*(\S(.*?\S)?)\*\*/gm, "<b>$1</b>");
chat = chat.replace(/\~\~(\S(.*?\S)?)\~\~/gm, "<s>$1</s>");
chat = chat.replace(/\*(\S(.*?\S)?)\*/gm, "<i>$1</i>");
-
- //TODO: For Blue:
- // I want the # in the to=$1 to turn into %23; but not anywhere else.
+
+ //Surround all URLs with a <a> link
var URLexp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
chat = chat.replace(URLexp, "<a href='redirect?to=$1' target='top'>$1</a>");
- //Here's to hoping no one puts a hash infront of a URL...
- chat = chat.replace(/\#/, "%23");
- //Here's for when someone does that and goes "wth?"
- //chat = chat.replace(/\#/g, "%23");
+
+ //Replace # in the URL with %23
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(#)(.*?)' target='top'>/ig, "<a href='redirect?to=$1%23$3' target='top'>");
return chat;
}
|