1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-04 15:05:47 +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() { get shortURL() {
let { uri, doc } = this; 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) for each (let shortener in Buffer.uriShorteners)
try { try {
let shortened = shortener(uri, doc); let shortened = shortener(uri, doc);
if (shortened) if (shortened)
return shortened.spec; return hashify(shortened.spec);
} }
catch (e) { catch (e) {
util.reportError(e); util.reportError(e);
@@ -637,7 +646,7 @@ var Buffer = Module("Buffer", {
let link = DOM("link[href][rev=canonical], \ let link = DOM("link[href][rev=canonical], \
link[href][rel=shortlink]", doc); link[href][rel=shortlink]", doc);
if (link) if (link)
return link.attr("href"); return hashify(link.attr("href"));
return null; return null;
}, },