osm-p2p-server
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -5,2 +5,10 @@ # Change Log | ||
## [2.0.2] | ||
### Fixed | ||
- Additional query string parameters do not break route matching (previously route matching was dependent on the order of query string parameters and including any query string parameter would cause route matching to 404) | ||
- All routes should return the correct charset (utf-8) on content-type, including error responses. This avoids strange bugs that might have resulted from the assumed charset of ISO-8859-1. | ||
### Changed | ||
- Update `split_delete_way.js` test so that it will run in the browser for osm-p2p-server-sw. | ||
## [2.0.1] | ||
@@ -51,2 +59,3 @@ ### Fixed | ||
[2.0.2]: https://github.com/digidem/osm-p2p-server/compare/2.0.1...2.0.2 | ||
[2.0.1]: https://github.com/digidem/osm-p2p-server/compare/2.0.0...2.0.1 | ||
@@ -53,0 +62,0 @@ [2.0.0]: https://github.com/digidem/osm-p2p-server/compare/2.0.0-beta3...2.0.0 |
@@ -46,2 +46,6 @@ { | ||
}, | ||
"MissingParameter": { | ||
"code": 400, | ||
"message": "Missing parameter '%s'.\nThe parameter has to be the same in the URL (e.g. /api/0.6/nodes?nodes=123,456,789)" | ||
}, | ||
"PlaceholderIdError": { | ||
@@ -48,0 +52,0 @@ "code": 400, |
@@ -22,3 +22,3 @@ var error = require('debug')('osm-p2p-server:error') | ||
var method = req.headers.x_http_method_override || req.method | ||
var m = this.match(method, req.url) | ||
var m = this.match(method, req.url.split('?')[0]) | ||
if (m) { | ||
@@ -42,3 +42,3 @@ res.setHeader('content-encoding', 'identity') | ||
res.statusCode = err.status | ||
res.setHeader('content-type', 'text/plain') | ||
res.setHeader('content-type', 'text/plain; charset=utf-8') | ||
res.end(err.message) | ||
@@ -45,0 +45,0 @@ } else { |
{ | ||
"name": "osm-p2p-server", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Peer-to-peer OpenStreetMap API v0.6 Server", | ||
@@ -49,6 +49,7 @@ "main": "index.js", | ||
"through2": "^2.0.1", | ||
"through2-map": "github:gmaclennan/through2-map", | ||
"through2-map": "^3.0.0", | ||
"xtend": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"content-type": "^1.0.2", | ||
"express": "^4.14.0", | ||
@@ -55,0 +56,0 @@ "fd-chunk-store": "^2.0.0", |
@@ -31,3 +31,3 @@ /** | ||
if (err) return next(err) | ||
res.setHeader('content-type', 'text/plain') | ||
res.setHeader('content-type', 'text/plain; charset=utf-8') | ||
res.end(id) | ||
@@ -34,0 +34,0 @@ }) |
@@ -21,3 +21,3 @@ var collect = require('collect-stream') | ||
if (err) return next(err) | ||
res.setHeader('content-type', 'text/plain') | ||
res.setHeader('content-type', 'text/plain; charset=utf-8') | ||
res.end(id + '\n') | ||
@@ -24,0 +24,0 @@ }) |
@@ -30,3 +30,3 @@ var collect = require('collect-stream') | ||
if (err) return next(err) | ||
res.setHeader('content-type', 'text/plain') | ||
res.setHeader('content-type', 'text/plain; charset=utf-8') | ||
res.end(diffResult.map(function (el) { return el.old_id }).join('\n')) | ||
@@ -33,0 +33,0 @@ }) |
@@ -9,7 +9,7 @@ var qs = require('query-string') | ||
module.exports = function (req, res, api, params, next) { | ||
if (params.type !== params.ktype) { | ||
return next(new errors.TypeMismatch(params.type, params.ktype)) | ||
var query = qs.parse(qs.extract(req.url)) | ||
if (!query[params.type]) { | ||
return next(new errors.MissingParameter(params.type)) | ||
} | ||
var query = qs.parse(qs.extract(req.url)) | ||
var ids = params.ids.split(',') | ||
var ids = query[params.type].split(',') | ||
var results = [] | ||
@@ -16,0 +16,0 @@ var pending = 1 |
@@ -6,3 +6,3 @@ var router = require('routes')() | ||
route('GET /api(/0.6)?/capabilities', require('./misc_capabilities.js')) | ||
route('GET /api/0.6/map?*', require('./misc_map.js')) | ||
route('GET /api/0.6/map', require('./misc_map.js')) | ||
route('PUT /api/0.6/:type(changeset)/create', require('./changeset_create.js')) | ||
@@ -15,3 +15,3 @@ route('POST /api/0.6/changeset/:id/upload', require('./changeset_upload.js')) | ||
route('GET /api/0.6/:type(node|way|relation)/:id/:version', require('./element_version.js')) | ||
route('GET /api/0.6/:type(nodes|ways|relations)\\?:ktype=:ids', require('./element_multi_fetch.js')) | ||
route('GET /api/0.6/:type(nodes|ways|relations)', require('./element_multi_fetch.js')) | ||
route('GET /api/0.6/:type(node|way|relation)/:id', require('./element_read.js')) | ||
@@ -18,0 +18,0 @@ route('DELETE /api/0.6/:type(node|way|relation)/:id', require('./element_delete')) |
@@ -18,3 +18,4 @@ var h = require('../lib/h.js') | ||
module.exports = function (req, res) { | ||
res.setHeader('content-type', 'text/xml; charset=utf-8') | ||
res.end(capabilities) | ||
} |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create bbox', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -40,3 +43,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('add docs to changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var docs = [] | ||
@@ -69,3 +72,5 @@ for (var i = 0; i < SIZE; i++) { | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -72,0 +77,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create bbox', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -40,3 +43,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('add docs to changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var docs = [] | ||
@@ -69,3 +72,5 @@ for (var i = 0; i < SIZE; i++) { | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -137,3 +142,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('missing bbox', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'map' | ||
@@ -143,3 +148,5 @@ var hq = hyperquest(href) | ||
t.equal(res.statusCode, 400) | ||
t.equal(res.headers['content-type'].split(/\s*;\s*/)[0], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -152,3 +159,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('invalid bbox', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'map?bbox=invalid' | ||
@@ -158,3 +165,5 @@ var hq = hyperquest(href) | ||
t.equal(res.statusCode, 400) | ||
t.equal(res.headers['content-type'].split(/\s*;\s*/)[0], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -167,3 +176,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('out of range bbox', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'map?bbox=-181,1,2,2' | ||
@@ -173,3 +182,5 @@ var hq = hyperquest(href) | ||
t.equal(res.statusCode, 400) | ||
t.equal(res.headers['content-type'].split(/\s*;\s*/)[0], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -176,0 +187,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -8,8 +9,8 @@ var hyperquest = require('hyperquest') | ||
var port, server | ||
var base, server | ||
test('capabilities.js: setup server', function (t) { | ||
createServer(function (d) { | ||
base = d.base | ||
server = d.server | ||
port = server.address().port | ||
t.end() | ||
@@ -20,4 +21,10 @@ }) | ||
test('capabilities', function (t) { | ||
t.plan(1) | ||
hyperquest('http://localhost:' + port + '/api/capabilities') | ||
t.plan(4) | ||
hyperquest(base + 'capabilities') | ||
.once('response', function (res) { | ||
t.equal(res.statusCode, 200, 'status 200') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
.pipe(concat({ encoding: 'string' }, function (body) { | ||
@@ -24,0 +31,0 @@ var data = parsexml(body) |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -44,3 +47,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('add docs', function (t) { | ||
t.plan(4 + 6) | ||
t.plan(5 + 6) | ||
@@ -53,3 +56,5 @@ var href = base + 'changeset/' + changeId + '/upload' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -56,0 +61,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset upload', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -44,3 +47,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('add docs to changeset upload', function (t) { | ||
t.plan(7) | ||
t.plan(8) | ||
@@ -53,3 +56,5 @@ var href = base + 'changeset/' + changeId + '/upload' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -158,3 +163,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('close already closed changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/' + changeId + '/close' | ||
@@ -164,3 +169,5 @@ var hq = hyperquest.put(href) | ||
t.equal(res.statusCode, 409, 'expected conflict code') | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -178,3 +185,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('upload to closed changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/' + changeId + '/upload' | ||
@@ -186,3 +193,5 @@ var hq = hyperquest.post(href, { | ||
t.equal(res.statusCode, 409, 'expected conflict code') | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -210,3 +219,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('create second changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -218,3 +227,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -233,3 +244,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('second changeset upload', function (t) { | ||
t.plan(10) | ||
t.plan(11) | ||
var href = base + 'changeset/' + secondChangeId + '/upload' | ||
@@ -241,3 +252,5 @@ var hq = hyperquest.post(href, { | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -244,0 +257,0 @@ var oldv, newv |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset upload', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -44,3 +47,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('add docs to changeset upload', function (t) { | ||
t.plan(8) | ||
t.plan(9) | ||
@@ -53,3 +56,5 @@ var href = base + 'changeset/' + changeId + '/upload' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -183,3 +188,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('close already closed changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/' + changeId + '/close' | ||
@@ -189,3 +194,5 @@ var hq = hyperquest.put(href) | ||
t.equal(res.statusCode, 409, 'expected conflict code') | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -203,3 +210,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('upload to closed changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/' + changeId + '/upload' | ||
@@ -211,3 +218,5 @@ var hq = hyperquest.post(href, { | ||
t.equal(res.statusCode, 409, 'expected conflict code') | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -235,3 +244,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('create second changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -243,3 +252,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -258,3 +269,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('second changeset upload', function (t) { | ||
t.plan(10) | ||
t.plan(11) | ||
var href = base + 'changeset/' + secondChangeId + '/upload' | ||
@@ -266,3 +277,5 @@ var hq = hyperquest.post(href, { | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -269,0 +282,0 @@ var oldv, newv |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset upload', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -44,3 +47,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('add docs to changeset upload', function (t) { | ||
t.plan(7) | ||
t.plan(8) | ||
@@ -53,3 +56,5 @@ var href = base + 'changeset/' + changeId + '/upload' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -158,3 +163,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('close already closed changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/' + changeId + '/close' | ||
@@ -164,3 +169,5 @@ var hq = hyperquest.put(href) | ||
t.equal(res.statusCode, 409, 'expected conflict code') | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -178,3 +185,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('upload to closed changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/' + changeId + '/upload' | ||
@@ -186,3 +193,5 @@ var hq = hyperquest.post(href, { | ||
t.equal(res.statusCode, 409, 'expected conflict code') | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -210,3 +219,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('create second changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -218,3 +227,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -233,3 +244,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('second changeset upload', function (t) { | ||
t.plan(10) | ||
t.plan(11) | ||
var href = base + 'changeset/' + secondChangeId + '/upload' | ||
@@ -241,3 +252,5 @@ var hq = hyperquest.post(href, { | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -244,0 +257,0 @@ var oldv, newv |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -46,3 +49,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('get empty osmchange doc', function (t) { | ||
t.plan(2) | ||
t.plan(5) | ||
var href = base + 'changeset/' + changeId + '/download' | ||
@@ -52,2 +55,8 @@ var hq = hyperquest(href, { | ||
}) | ||
hq.once('response', function (res) { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
@@ -66,3 +75,3 @@ var xml = parsexml(body) | ||
] | ||
t.plan(docs.length * 3) | ||
t.plan(docs.length * 4) | ||
docs.forEach(function (doc) { | ||
@@ -75,3 +84,5 @@ var href = base + doc.type + '/create' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -93,3 +104,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('get doc versions', function (t) { | ||
t.plan(6) | ||
t.plan(8) | ||
Object.keys(uploaded).forEach(function (key) { | ||
@@ -100,3 +111,5 @@ var href = base + 'node/' + uploaded[key] | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -103,0 +116,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -44,3 +47,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('add docs', function (t) { | ||
t.plan(4 + 6) | ||
t.plan(5 + 6) | ||
@@ -53,3 +56,5 @@ var href = base + 'changeset/' + changeId + '/upload' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -56,0 +61,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -38,3 +39,3 @@ var hyperquest = require('hyperquest') | ||
] | ||
t.plan(6 * updates.length) | ||
t.plan(7 * updates.length) | ||
var exists = {} | ||
@@ -50,3 +51,5 @@ var versionId = {} | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -123,3 +126,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('history route', function (t) { | ||
t.plan(4) | ||
t.plan(5) | ||
var hq = hyperquest(base + 'node/' + ids.A + '/history', { | ||
@@ -130,3 +133,5 @@ headers: { 'content-type': 'text/xml' } | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -133,0 +138,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var hyperquest = require('hyperquest') | ||
@@ -19,3 +20,3 @@ var concat = require('concat-stream') | ||
test('send malformed changeset upload', function (t) { | ||
t.plan(2) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,2 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.notEqual(res.statusCode, 200, 'malformed xml error code') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -29,0 +33,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -20,3 +21,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -28,3 +29,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -69,3 +72,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
] | ||
t.plan(docs.length * 3) | ||
t.plan(docs.length * 4) | ||
;(function next () { | ||
@@ -90,3 +93,5 @@ if (docs.length === 0) return | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -123,3 +128,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('multi-fetch ways', function (t) { | ||
t.plan(6) | ||
t.plan(7) | ||
var href = base + 'ways?ways=' + keys.G + ',' + keys.H | ||
@@ -131,3 +136,5 @@ var hq = hyperquest(href, { | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -147,3 +154,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('get relation', function (t) { | ||
t.plan(5) | ||
t.plan(6) | ||
var href = base + 'relation/' + keys.I | ||
@@ -155,3 +162,5 @@ var hq = hyperquest(href, { | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -158,0 +167,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -19,3 +20,3 @@ var hyperquest = require('hyperquest') | ||
test('create changeset', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -27,3 +28,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -51,3 +54,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
] | ||
t.plan(docs.length * 3) | ||
t.plan(docs.length * 4) | ||
docs.forEach(function (doc) { | ||
@@ -60,3 +63,5 @@ var href = base + doc.type + '/create' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/plain') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -77,3 +82,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('multi-fetch', function (t) { | ||
t.plan(6) | ||
t.plan(7) | ||
var ids = Object.keys(uploaded) | ||
@@ -87,3 +92,5 @@ .map(function (key) { return uploaded[key] }) | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -102,2 +109,47 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('multi-fetch random parameters in query string', function (t) { | ||
t.plan(7) | ||
var ids = Object.keys(uploaded) | ||
.map(function (key) { return uploaded[key] }) | ||
var href = base + 'nodes?foo=bar&nodes=' + ids.join(',') | ||
var hq = hyperquest(href, { | ||
headers: { 'content-type': 'text/xml' } | ||
}) | ||
hq.once('response', function (res) { | ||
t.equal(res.statusCode, 200) | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
var xml = parsexml(body) | ||
t.equal(xml.root.name, 'osm') | ||
t.equal(xml.root.children[0].name, 'node') | ||
t.equal(xml.root.children[1].name, 'node') | ||
var xids = xml.root.children.map(function (x) { | ||
return x.attributes.id | ||
}) | ||
t.deepEqual(xids, ids, 'id comparison') | ||
})) | ||
}) | ||
test('multi-fetch error', function (t) { | ||
t.plan(4) | ||
var ids = Object.keys(uploaded) | ||
.map(function (key) { return uploaded[key] }) | ||
var href = base + 'nodes?ways=' + ids.join(',') | ||
var hq = hyperquest(href, { | ||
headers: { 'content-type': 'text/xml' } | ||
}) | ||
hq.once('response', function (res) { | ||
t.equal(res.statusCode, 400) | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
t.equal(body.split('\n')[0], 'Missing parameter \'nodes\'.') | ||
})) | ||
}) | ||
test('multi_fetch.js: teardown server', function (t) { | ||
@@ -104,0 +156,0 @@ server.cleanup() |
var test = require('tape') | ||
var contentType = require('content-type') | ||
var parsexml = require('xml-parser') | ||
@@ -8,3 +9,3 @@ var hyperquest = require('hyperquest') | ||
var base, server, changeId, changeId2, osm | ||
var base, server, changeId, changeId2 | ||
@@ -15,3 +16,2 @@ test('split_way_delete.js: setup server', function (t) { | ||
server = d.server | ||
osm = d.osm | ||
t.end() | ||
@@ -22,3 +22,3 @@ }) | ||
test('create changeset (1)', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -30,3 +30,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -48,3 +50,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('create way with changeset upload', function (t) { | ||
t.plan(10) | ||
t.plan(11) | ||
@@ -57,3 +59,5 @@ var href = base + 'changeset/' + changeId + '/upload' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -96,3 +100,5 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
t.equal(res.statusCode, 200, 'response code correct') | ||
t.equal(res.headers['content-type'].split(/\s*;\s*/)[0], 'text/xml', 'content-type good') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -119,3 +125,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('create changeset (2)', function (t) { | ||
t.plan(3) | ||
t.plan(4) | ||
var href = base + 'changeset/create' | ||
@@ -127,3 +133,5 @@ var hq = hyperquest.put(href, { | ||
t.equal(res.statusCode, 200, 'create 200 ok') | ||
t.equal(res.headers['content-type'], 'text/plain', 'create content type') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/plain', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -142,3 +150,3 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('split way and delete half changeset upload', function (t) { | ||
t.plan(6) | ||
t.plan(7) | ||
@@ -151,3 +159,5 @@ var href = base + 'changeset/' + changeId2 + '/upload' | ||
t.equal(res.statusCode, 200) | ||
t.equal(res.headers['content-type'], 'text/xml; charset=utf-8') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -183,10 +193,18 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
test('Check modified way', function (t) { | ||
osm.get(ids['-6'], function (err, docs) { | ||
t.error(err, "doesn't throw error") | ||
t.equal(Object.keys(docs).length, 1, 'no forks created') | ||
var way = docs[Object.keys(docs)[0]] | ||
t.equal(way.changeset, changeId2) | ||
t.deepEqual(way.refs.sort(), [ids['-1'], ids['-2'], ids['-3']].sort()) | ||
var href = base + 'way/' + ids['-6'] + '?forks=true' | ||
var hq = hyperquest(href) | ||
hq.once('response', function (res) { | ||
t.equal(res.statusCode, 200, 'response code correct') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
var elements = parsexml(body).root.children | ||
t.equal(elements.length, 1, 'no forks created') | ||
t.equal(elements[0].attributes.changeset, changeId2) | ||
var nodeIds = elements[0].children.map(function (c) { return c.attributes.ref }) | ||
t.deepEqual(nodeIds.sort(), [ids['-1'], ids['-2'], ids['-3']].sort()) | ||
t.end() | ||
}) | ||
})) | ||
}) | ||
@@ -199,3 +217,5 @@ | ||
t.equal(res.statusCode, 200, 'response code correct') | ||
t.equal(res.headers['content-type'].split(/\s*;\s*/)[0], 'text/xml', 'content-type good') | ||
var contentObj = contentType.parse(res) | ||
t.equal(contentObj.type, 'text/xml', 'media type correct') | ||
t.equal(contentObj.parameters.charset.toLowerCase(), 'utf-8', 'charset correct') | ||
}) | ||
@@ -202,0 +222,0 @@ hq.pipe(concat({ encoding: 'string' }, function (body) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
182529
5049
0
12
+ Addedreadable-stream@3.6.2(transitive)
+ Addedthrough2@4.0.2(transitive)
+ Addedthrough2-map@3.1.0(transitive)
Updatedthrough2-map@^3.0.0