Skip to content

Commit 2443ed7

Browse files
committed
fixup! use match group for regex
1 parent 0db85dc commit 2443ed7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/unit/node/update.test.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ describe("update", () => {
4545
return response.end()
4646
}
4747

48-
// NOTES subpath match /redirect/${number}
49-
// if number === 0, resolve it
50-
if (request.url.match(/\/redirect\/[0-9]/)) {
48+
// Checks if url matches /redirect/${number}
49+
// with optional trailing slash
50+
let redirectSlashNumberRegExp = new RegExp(/\/redirect\/([0-9]+)(\/)?$/)
51+
52+
if (request.url.match(redirectSlashNumberRegExp)) {
5153
if (request.url === "/redirect/0") {
5254
response.writeHead(200)
5355
return response.end("done")
@@ -259,7 +261,7 @@ describe("update", () => {
259261

260262
it("should reject if more than 10 redirects", async () => {
261263
if (isAddressInfo(_address)) {
262-
const mockURL = `http://${_address.address}:${_address.port}/redirect/10`
264+
const mockURL = `http://${_address.address}:${_address.port}/redirect/11`
263265
let provider = new UpdateProvider(mockURL, settings())
264266
let update = await provider.getUpdate(true)
265267

0 commit comments

Comments
 (0)