summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2014-01-06 04:00:28 +0100
committerlassulus <lassulus@googlemail.com>2014-01-06 04:00:28 +0100
commitf70fac7542f653409862b079e8be76a42e06b063 (patch)
tree84225781cf0ffe04a6c15e70f0f0f7684c095c02
parentcb1e01ce514770696b53ceb981d839815efbf612 (diff)
parent2c5e272f70fe55556669a547709aaf4019239951 (diff)
Merge branch 'master' of github.com:krebscode/painload
-rw-r--r--go/README.markdown4
-rw-r--r--go/index.js8
2 files changed, 11 insertions, 1 deletions
diff --git a/go/README.markdown b/go/README.markdown
index 87e0541e..2d4ba909 100644
--- a/go/README.markdown
+++ b/go/README.markdown
@@ -23,6 +23,10 @@
REDIS_KEY_PREFIX=foobarmyprefix/
+ to generate slightly more informative shortened uris set
+
+ NOT_SO_SHORT=true
+
## add uri
curl -F uri=https://mywaytoolonguri http://go
diff --git a/go/index.js b/go/index.js
index 7f1e6a07..3bac2f7b 100644
--- a/go/index.js
+++ b/go/index.js
@@ -3,6 +3,7 @@ var hostname = process.env.HOSTN;
var httpPort = process.env.PORT;
var uriPrefix = process.env.URI_PREFIX;
var redisPrefix = process.env.REDIS_KEY_PREFIX;
+var appendDomainToUri = process.env.NOT_SO_SHORT === 'true';
// automatic configuration
@@ -25,6 +26,7 @@ if (!redisPrefix) {
// load libraries
var http = require('http');
+var url = require('url');
var formidable = require('formidable');
var redis = require('redis');
@@ -79,6 +81,10 @@ function create (req, res) {
return internalError(err, req, res);
}
+ if (appendDomainToUri) {
+ shortUri += '#' + url.parse(uri).host
+ }
+
res.writeHead(200, { 'content-type': 'text/plain' });
return res.end(shortUri + '\r\n');
});
@@ -87,7 +93,7 @@ function create (req, res) {
}
function retrieve (req, res) {
- var key = redisPrefix + req.url;
+ var key = redisPrefix + url.parse(req.url).path;
redisClient.get(key, function (error, reply) {
if (error) {
return internalError(err, req, res);