Modify linkToUrl() to use display_url and expanded_url in the input entity. #54

Merged
merged 8 commits into from May 5, 2012

Projects

None yet

3 participants

@keitaf
Contributor
keitaf commented Mar 30, 2012

This modifies linkToUrl() to use display_url and expanded_url if they are available in the input entity.

This still uses options.urlEntities if provided.

@couch couch and 1 other commented on an outdated diff May 1, 2012
twitter-text.js
+ // <span style='font-size:0'>&nbsp;</span>
+ // </span>
+ // <span style='font-size:0'> <!-- This stuff should get copied but not displayed -->
+ // http://longdomai
+ // </span>
+ // <span class='js-display-url'> <!-- This stuff should get displayed *and* copied -->
+ // nname.com/foo
+ // </span>
+ // <span class='tco-ellipsis'> <!-- This stuff should get displayed but not copied -->
+ // <span style='font-size:0'>&nbsp;</span>
+ //
+ // </span>
+ v['invisible'] = "style='font-size:0; line-height:0'";
+ return stringSupplant("<span class='tco-ellipsis'>#{precedingEllipsis}<span #{invisible}>&nbsp;</span></span><span #{invisible}>#{beforeDisplayUrl}</span><span class='js-display-url'>#{displayUrlSansEllipses}</span><span #{invisible}>#{afterDisplayUrl}</span><span class='tco-ellipsis'><span #{invisible}>&nbsp;</span>#{followingEllipsis}</span>", v);
+ }
+ return dispalyUrl;
@couch
couch May 1, 2012 Contributor

displayUrl is misspelled here.

@keitaf
keitaf May 2, 2012 Contributor

fixed.

@couch couch and 1 other commented on an outdated diff May 1, 2012
twitter-text.js
@@ -519,6 +459,73 @@ if (typeof twttr === "undefined" || twttr === null) {
return stringSupplant("<a href=\"#{url}\"#{htmlAttrs}>#{linkText}</a>", d);
};
+ twttr.txt.linkTextWithEntity = function (entity) {
@couch
couch May 1, 2012 Contributor

This function should probably have a test. It's not entirely clear what form the entity object should take.

@keitaf
keitaf May 2, 2012 Contributor

Thank you for the review! I added unit tests for linkTextWithEntity and also fixed a typo.

@hoverbird
Contributor

Awesome, tests and code look good to me.

@couch couch merged commit 87ca503 into master May 5, 2012
@caniszczyk caniszczyk deleted the use_displayurl_in_entity branch Mar 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment