Skip to content

Instantly share code, notes, and snippets.

@iamued
Created January 9, 2012 06:17
Show Gist options
  • Save iamued/1581445 to your computer and use it in GitHub Desktop.
Save iamued/1581445 to your computer and use it in GitHub Desktop.
short url cover for Mac
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/");
#!/bin/sh
if [ $1 ]
then
curl -s "http://uedpark.com:1230/?url="$1 | pbcopy
echo "已经复制到剪切板:" && pbpaste
else
echo "error:no url"
fi
@iamued
Copy link
Author

iamued commented Jan 9, 2012

url.sh是在mac终端下执行的shell
直接sh url.sh http://.....
在mac下会自动把转换后的网址复制到剪切板的

url.js 依赖于 traceurl https://github.com/CatChen/traceurl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment