[PATCH] Add URI shortener for amazon sites

25 views
Skip to first unread message

Lucy Inaba

unread,
Nov 2, 2013, 2:54:32 PM11/2/13
to dactyl-...@googlegroups.com
# HG changeset patch
# User lucy <ne.t...@gmail.com>
# Date 1383418422 -3600
# Sat Nov 02 19:53:42 2013 +0100
# Node ID a94ce16924bcfd335d967f0ada8881efe9aa33d7
# Parent d53ebde9c3e145447cc7ad41a482493d383e2b83
Add URI shortener for amazon sites

diff -r d53ebde9c3e1 -r a94ce16924bc common/modules/buffer.jsm
--- a/common/modules/buffer.jsm Sat Nov 02 22:16:03 2013 +1100
+++ b/common/modules/buffer.jsm Sat Nov 02 19:53:42 2013 +0100
@@ -2716,6 +2716,14 @@
return video ? util.newURI("http://youtu.be/" + video) : null;
});

+// gets rid of unnecessary cruft from amazon links
+Buffer.addURIShortener((uri, doc) => {
+ return /amazon\.(?:at|ca|co\.(?:jp|uk)|com|de|es|fr|it)/.test(uri.host);
+}, (uri, doc) => {
+ let path = uri.path.split("/");
+ return path[2] == "dp" && path[3] ? util.newURI(uri.prePath +
"/dp/" + path[3]) : null;
+});
+
// catch(e){ if (!e.stack) e = Error(e);
dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }

endModule();

Lucy Inaba

unread,
Nov 2, 2013, 9:13:03 PM11/2/13
to dactyl-...@googlegroups.com
Never mind this. It's fairly incomplete and I discovered that it's
trivially implemented as a plugin.

Kris Maglione

unread,
Nov 2, 2013, 9:18:09 PM11/2/13
to Lucy Inaba, dactyl-...@googlegroups.com
I agree that this would be better implemented as a plugin. We
added a special case shortener for YouTube because YouTube's
builtin shortener is broken, but in general I'd prefer not to
have site-specific shorteners in core.
>--
>You received this message because you are subscribed to the Google Groups "Dactyl Patches" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to dactyl-patche...@googlegroups.com.
>For more options, visit https://groups.google.com/groups/opt_out.

--
Kris Maglione

Good judgement comes from experience, and experience comes from bad
judgement.
--Fred Brooks

Reply all
Reply to author
Forward
0 new messages