Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Apply stricter extraction rule for t.co URLs in autoLinkUrlCustom(). #24

Merged
merged 1 commit into from

2 participants

@keitaf
Collaborator

This will apply the same rule as in #22 onto autoLinkUrlCustom() to correctly auto link t.co URL.

@klingerf
Collaborator

Looks good to me

@keitaf keitaf merged commit a884e1d into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 2 deletions.
  1. +10 −2 twitter-text.js
View
12 twitter-text.js
@@ -450,14 +450,22 @@ 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);
@@ -465,7 +473,7 @@ if (!window.twttr) {
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;
}
Something went wrong with that request. Please try again.