Skip to content

Commit

Permalink
Fix a bug in extractURlsWithIndices to correctly extract URLs without…
Browse files Browse the repository at this point in the history
… protocol.
  • Loading branch information
keita committed Nov 15, 2011
1 parent 41fb445 commit 658e5e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions twitter-text.js
Expand Up @@ -575,7 +575,7 @@ if (!window.twttr) {
// if protocol is missing and domain contains non-ASCII characters,
// extract ASCII-only domains.
if (!protocol) {
var lastUrl,
var lastUrl = null,
lastUrlInvalidMatch = false,
asciiEndPosition = 0;
domain.replace(twttr.txt.regexen.validAsciiDomain, function(asciiDomain) {
Expand All @@ -591,10 +591,12 @@ if (!window.twttr) {
}
});

if (urls.length == 0) {
// no ASCII-only domain found. Skip the entire URL.
if (lastUrl == null) {
return;
}

// lastUrl only contains domain. Need to add path and query if they exist.
if (path) {
if (lastUrlInvalidMatch) {
urls.push(lastUrl);
Expand Down

0 comments on commit 658e5e5

Please sign in to comment.