aboutsummaryrefslogtreecommitdiffstats
path: root/bitly.js
diff options
context:
space:
mode:
authoranekos2010-05-06 13:01:30 +0000
committeranekos2010-05-06 13:01:30 +0000
commitfb448617719bec7e503908c626688fd403e4fe7b (patch)
treec02e1988b5b3fec6536c48c31572aa75d22e02aa /bitly.js
parent99c9c6759d0d5017c730c137234fbedd674082d0 (diff)
downloadvimperator-plugins-fb448617719bec7e503908c626688fd403e4fe7b.tar.bz2
引数のURLを省略できるように > API
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37401 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'bitly.js')
-rw-r--r--bitly.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/bitly.js b/bitly.js
index 3dd63f7..f0d8103 100644
--- a/bitly.js
+++ b/bitly.js
@@ -38,7 +38,7 @@ let PLUGIN_INFO =
<name>bit.ly</name>
<description>Get short alias by bit.ly and j.mp</description>
<description lang="ja">bit.ly や j.mp で短縮URLを得る</description>
- <version>2.0.1</version>
+ <version>2.0.2</version>
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
<license>new BSD License (Please read the source code comments of this plugin)</license>
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
@@ -95,7 +95,7 @@ let PLUGIN_INFO =
);
}
- function shorten (uri, domain, callback) {
+ function shorten (url, domain, callback) {
function get () {
let req = new XMLHttpRequest();
req.onreadystatechange = function () {
@@ -110,7 +110,7 @@ let PLUGIN_INFO =
ApiUrl + '/shorten?' +
'apiKey=' + auth.password + '&' +
'login=' + auth.username + '&' +
- 'uri=' + encodeURIComponent(uri) + '&' +
+ 'uri=' + encodeURIComponent(url) + '&' +
'domain=' + (domain || 'bit.ly') + '&' +
'format=txt';
req.open('GET', requestUri, callback);
@@ -118,6 +118,9 @@ let PLUGIN_INFO =
return !callback && req.responseText.trim();
}
+ if (!url)
+ url = buffer.URL;
+
let auth = getAuth();
if (auth)
@@ -138,9 +141,9 @@ let PLUGIN_INFO =
[name],
'Copy ' + domain + ' url',
function (args) {
- let url = args.literalArg ? util.stringToURLArray(args.literalArg)[0] : buffer.URL;
+ let url = args.literalArg && util.stringToURLArray(args.literalArg)[0];
- shorten(url || buffer.URL, domain, function (short) {
+ shorten(url, domain, function (short) {
util.copyToClipboard(short);
liberator.echo(short + ' <= ' + url);
});