Skip to content

Commit

Permalink
[derived-versions][xs]: fixed redirects for derived versions of tabul…
Browse files Browse the repository at this point in the history
…ar resources

* after changes in the backend (assembler) paths for derived versions of resources have changed. This commit addresses fixes for those changes so frontend works as expected.
  • Loading branch information
anuveyatsu committed Sep 18, 2017
1 parent cb52f85 commit 3be7ce0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ module.exports = function () {
resource = resource.alternates.find(res => extension.substring(1) === res.format)
}

res.redirect(`${normalizedDp.path}/${resource.path}`)
res.redirect(`${resource.path}`)
})

router.get('/search', async (req, res) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/demo-package/datapackage.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"hash": "b0503f17cecc447d595aa9a7f0f4455b",
"mediatype": "text/csv",
"name": "demo-resource_csv",
"path": "data/csv/data/demo-resource.csv",
"path": "http://localhost:4000/admin/demo-package:demo-resource_csv/data/demo-resource_csv.csv",
"rowcount": 651,
"schema": {
"fields": [
Expand Down Expand Up @@ -90,7 +90,7 @@
"hash": "e68e179acaa858b500a02ab80512efcd",
"mediatype": "text/csv",
"name": "demo-resource_json",
"path": "data/json/data/demo-resource.json",
"path": "http://localhost:4000/admin/demo-package:demo-resource_json/data/demo-resource_json.json",
"rowcount": 651,
"schema": {
"fields": [
Expand Down
8 changes: 4 additions & 4 deletions tests/routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ test('Downloading a resource by name or index works for csv and json', async t =
let res = await request(app)
.get('/admin/demo-package/r/demo-resource.csv')
t.is(res.statusCode, 302)
t.true(res.header.location.includes('/latest/data/csv/data/demo-resource.csv'))
t.true(res.header.location.includes('data/demo-resource_csv.csv'))
res = await request(app)
.get('/admin/demo-package/r/demo-resource.json')
t.is(res.statusCode, 302)
t.true(res.header.location.includes('/latest/data/json/data/demo-resource.json'))
t.true(res.header.location.includes('data/demo-resource_json.json'))
res = await request(app)
.get('/admin/demo-package/r/0.csv')
t.is(res.statusCode, 302)
t.true(res.header.location.includes('/latest/data/csv/data/demo-resource.csv'))
t.true(res.header.location.includes('data/demo-resource_csv.csv'))
res = await request(app)
.get('/admin/demo-package/r/0.json')
t.is(res.statusCode, 302)
t.true(res.header.location.includes('/latest/data/json/data/demo-resource.json'))
t.true(res.header.location.includes('data/demo-resource_json.json'))
})

test('Redirects to old.datahub.io', async t => {
Expand Down

0 comments on commit 3be7ce0

Please sign in to comment.