Skip to content

Commit

Permalink
.href will translate relative URLs to absolute ones. Hawt!
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Wenzel committed Jul 23, 2010
1 parent 62e31eb commit 7d07025
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function findShortUrl(ctx) {
let doc = ctx.document,
short = doc.querySelector(selectors),
link;
if (short && (link = short.getAttribute('href')))
if (short && (link = short.href))
return link;
return false;
}
Expand All @@ -20,8 +20,9 @@ function createShortUrl(ctx) {
url, canonical;
// use canonical URL if it exists, current URL otherwise.
canonical = ctx.document.querySelector('link[rel=canonical]');
if (!(canonical && (url = canonical.getAttribute('href'))))
if (!(canonical && (url = canonical.href)))
url = ctx.document.URL;

req.open("GET", "http://tinyurl.com/api-create.php?url="
+encodeURIComponent(url), false);
req.send(null);
Expand All @@ -47,4 +48,3 @@ exports.main = function() {
});
contextMenu.add(item);
}

0 comments on commit 7d07025

Please sign in to comment.