Skip to content

Instantly share code, notes, and snippets.

@littlefolk
Created June 3, 2010 11:08
Show Gist options
  • Save littlefolk/423749 to your computer and use it in GitHub Desktop.
Save littlefolk/423749 to your computer and use it in GitHub Desktop.
vimperator plugin: urlcanonicalize
// :urlcanonicalize, :urlnormalize --- URL正規化 {{{
// @http://pathtraq.com/developer/#help_normalize_url
// @http://d.hatena.ne.jp/janus_wel/20080924/1222244725
commands.addUserCommand(
['url[canonicalize]', 'url[normalize]'], 'URL Canonicalization',
function (arg) {
if (arg.bang)
{
let req = new libly.Request("http://api.pathtraq.com/normalize_url2?url=" + buffer.URL);
req.addEventListener("onSuccess", function (res) liberator.open(libly.$U.evalJson(res.responseText)));
req.get();
}
else
if (~buffer.URL.indexOf("&")) liberator.open(buffer.URL.split("&")[0]);
},
{
bang: true
},
true
);
// }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment