Skip to content

Instantly share code, notes, and snippets.

@yanwen
Forked from iamued/url.js
Created January 9, 2012 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanwen/1583599 to your computer and use it in GitHub Desktop.
Save yanwen/1583599 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment