summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md3
-rw-r--r--routes/index.js6
-rw-r--r--test/split.js19
-rw-r--r--views/data.jade2
4 files changed, 25 insertions, 5 deletions
diff --git a/TODO.md b/TODO.md
index 74f0585..4b45e26 100644
--- a/TODO.md
+++ b/TODO.md
@@ -29,3 +29,6 @@
collection+json documents.
Make interactive so people can collaborate on a single specification.
+
+* BUG: when executing queries, the URL in the "http response" section
+ is not the correct url, it's missing the query parameters.
diff --git a/routes/index.js b/routes/index.js
index b7ec0c4..702ec0f 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -25,8 +25,14 @@ function split(str) {
}
});
+ // Append the query as a single segment
+ // If not query, append the slash slash if it's missing.
if(u.search) {
splits.push([(u.pathname.match(/\/$/) ? '/' : '') + u.search, url.format(u)]);
+ } else if(str.match(/\/$/)) {
+ var last = splits[splits.length - 1];
+ last[0] = last[0] + '/';
+ last[1] = last[1] + '/';
}
return splits;
diff --git a/test/split.js b/test/split.js
index 4bf8277..ece6b5f 100644
--- a/test/split.js
+++ b/test/split.js
@@ -4,15 +4,26 @@ var assert = require('assert')
function assertSplit(url, expected) {
var actual = routes.split(url);
- // console.log('actual ', util.inspect(actual));
// console.log('expected', util.inspect(expected));
- assert.deepEqual(actual, expected);
+ // console.log('actual ', util.inspect(actual));
+ assert.equal(util.inspect(expected), util.inspect(actual));
}
describe('routes.split', function() {
+ it('http://localhost:123', function() {
+ assertSplit('http://localhost:123', [
+ ['http://localhost:123','http://localhost:123']
+ ]);
+ });
it('http://localhost:123/', function() {
assertSplit('http://localhost:123/', [
- ['http://localhost:123','http://localhost:123']
+ ['http://localhost:123/','http://localhost:123/']
+ ]);
+ });
+ it('http://localhost:123/?a=b', function() {
+ assertSplit('http://localhost:123/?a=b', [
+ ['http://localhost:123','http://localhost:123'],
+ ['/?a=b','http://localhost:123/?a=b']
]);
});
it('http://localhost:123/foo', function() {
@@ -24,7 +35,7 @@ describe('routes.split', function() {
it('http://localhost:123/foo/', function() {
assertSplit('http://localhost:123/foo/', [
['http://localhost:123','http://localhost:123'],
- ['/foo','http://localhost:123/foo'],
+ ['/foo/','http://localhost:123/foo/'],
]);
});
it('http://localhost:123/a?x=1&y=2', function() {
diff --git a/views/data.jade b/views/data.jade
index 3d844a3..948053b 100644
--- a/views/data.jade
+++ b/views/data.jade
@@ -8,7 +8,7 @@ mixin get_name(link, prefix, i)
// TODO: Show show a 'copy' button to copy the entire link
mixin href(href)
- if typeof href != 'string'
+ if typeof href !== 'string'
i no href
else
- var splits = urlgenerator.split(href)