Skip to content

Commit 484b7f0

Browse files
committed
add optional /update/ path prefix. closes #7
1 parent 7a39418 commit 484b7f0

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ WIP public electron update server.
44

55
## Routes
66

7-
### `/:owner/:repo/:platform/:version`
8-
### `/:owner/:repo/win32/:version/RELEASES`
7+
### `/update?/:owner/:repo/:platform/:version`
8+
### `/update?/:owner/:repo/win32/:version/RELEASES`
99

1010
## Development
1111

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Updates {
3030

3131
async handle (req, res) {
3232
this.log(req.method, req.url, '...')
33-
const segs = req.url.split(/[/?]/).filter(Boolean)
33+
let segs = req.url.split(/[/?]/).filter(Boolean)
34+
if (segs[0] === 'update') segs = segs.slice(1)
3435
const [account, repository, platform, version, file] = segs
3536
if (!account || !repository || !platform || !version) {
3637
notFound(res)

test/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ test('Updates', async t => {
3939
}
4040
})
4141

42+
await t.test('optional /update/ path prefix', async t => {
43+
for (let i = 0; i < cache; i++) {
44+
const res = await fetch(
45+
`${address}/update/dat-land/dat-desktop/darwin/1.0.0`
46+
)
47+
t.equal(res.status, 200)
48+
const body = await res.json()
49+
t.ok(body.name)
50+
t.match(body.url, /-mac\.zip$/)
51+
t.ok(body.notes)
52+
}
53+
})
54+
4255
await t.test('exists but no updates', async t => {
4356
let res = await fetch(
4457
`https://api.github.com/repos/dat-land/dat-desktop/releases?per_page=100`,

0 commit comments

Comments
 (0)