Fix autolinking for urls with non-English characters

Fixes #559

https://url.spec.whatwg.org/#url-code-points

// FREEBIE
This commit is contained in:
lilia 2016-01-01 06:14:25 -08:00
parent 3d55f2c125
commit d03d6fb7a5

View file

@ -5,6 +5,8 @@
'use strict';
window.Whisper = window.Whisper || {};
var URL_REGEX = /(^|[\s\n]|<br\/?>)((?:https?|ftp):\/\/[\-A-Z0-9\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFFD+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
Whisper.MessageView = Whisper.View.extend({
tagName: "li",
templateName: 'message',
@ -89,7 +91,7 @@
var content = this.$('.content');
var escaped = content.html();
content.html(escaped.replace(/\n/g, '<br>').replace(/(^|[\s\n]|<br\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi, "$1<a href='$2' target='_blank'>$2</a>"));
content.html(escaped.replace(/\n/g, '<br>').replace(URL_REGEX, "$1<a href='$2' target='_blank'>$2</a>"));
this.renderSent();
this.renderDelivered();