1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 07:14:13 +01:00

Preserve fragment ID when yanking short URLs.

This commit is contained in:
Kris Maglione
2013-11-02 12:26:34 -07:00
parent 98da57f22f
commit 64978d071f

View File

@@ -624,11 +624,20 @@ var Buffer = Module("Buffer", {
get shortURL() {
let { uri, doc } = this;
function hashify(url) {
let newURI = util.newURI(url);
if (uri.hasRef && !newURI.hasRef)
newURI.ref = uri.ref;
return newURI.spec;
}
for each (let shortener in Buffer.uriShorteners)
try {
let shortened = shortener(uri, doc);
if (shortened)
return shortened.spec;
return hashify(shortened.spec);
}
catch (e) {
util.reportError(e);
@@ -637,7 +646,7 @@ var Buffer = Module("Buffer", {
let link = DOM("link[href][rev=canonical], \
link[href][rel=shortlink]", doc);
if (link)
return link.attr("href");
return hashify(link.attr("href"));
return null;
},