Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Apply stricter extraction rule for t.co URLs in autoLinkUrlCustom().
Browse files Browse the repository at this point in the history
  • Loading branch information
keita committed Dec 2, 2011
1 parent 4616924 commit 0b56b16
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions twitter-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,22 +450,30 @@ if (!window.twttr) {

if (protocol) {
var htmlAttrs = "";
var after = "";
for (var k in options) {
htmlAttrs += stringSupplant(" #{k}=\"#{v}\" ", {k: k, v: options[k].toString().replace(/"/, "&quot;").replace(/</, "&lt;").replace(/>/, "&gt;")});
}

// In the case of t.co URLs, don't allow additional path characters.
if (url.match(twttr.txt.regexen.validTcoUrl)) {
url = RegExp.lastMatch;
after = RegExp.rightContext;
}

var d = {
before: before,
htmlAttrs: htmlAttrs,
url: twttr.txt.htmlEscape(url)
url: twttr.txt.htmlEscape(url),
after: after
};
if (urlEntities && urlEntities[url] && urlEntities[url].display_url) {
d.displayUrl = twttr.txt.htmlEscape(urlEntities[url].display_url);
} else {
d.displayUrl = d.url;
}

return stringSupplant("#{before}<a href=\"#{url}\"#{htmlAttrs}>#{displayUrl}</a>", d);
return stringSupplant("#{before}<a href=\"#{url}\"#{htmlAttrs}>#{displayUrl}</a>#{after}", d);
} else {
return all;
}
Expand Down

0 comments on commit 0b56b16

Please sign in to comment.