Created
January 9, 2012 06:17
-
-
Save iamued/1581445 to your computer and use it in GitHub Desktop.
short url cover for Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
const traceurl = require('traceurl'); | |
var url =require('url'); | |
var server = http.createServer(function (request, response) { | |
response.writeHead(200, {"Content-Type": "text/plain"}); | |
//console.log("request"+url.parse(request.url).query); | |
var urlreq=url.parse(request.url,true).query; | |
if(urlreq!=''){ | |
if(urlreq.url){ | |
traceurl(urlreq.url).addCallback(function(resolvedUrl) { | |
response.end(resolvedUrl+"\n"); | |
}); | |
}else{ | |
response.end("error"); | |
} | |
} | |
}); | |
server.listen(1230); | |
console.log("Server running at http://127.0.0.1:1230/"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $1 ] | |
then | |
curl -s "http://uedpark.com:1230/?url="$1 | pbcopy | |
echo "已经复制到剪切板:" && pbpaste | |
else | |
echo "error:no url" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
url.sh是在mac终端下执行的shell
直接sh url.sh http://.....
在mac下会自动把转换后的网址复制到剪切板的
url.js 依赖于 traceurl https://github.com/CatChen/traceurl