diff --git a/deno_dist/client/utils.ts b/deno_dist/client/utils.ts index aea09122a..517993619 100644 --- a/deno_dist/client/utils.ts +++ b/deno_dist/client/utils.ts @@ -16,7 +16,7 @@ export const replaceUrlParam = (urlString: string, params: Record { - return urlSting.replace(/\/index$/, '/') + return urlSting.replace(/\/index$/, '') } function isObject(item: unknown): item is ObjectType { diff --git a/src/client/utils.test.ts b/src/client/utils.test.ts index a67a0140e..32ddfe415 100644 --- a/src/client/utils.test.ts +++ b/src/client/utils.test.ts @@ -43,18 +43,18 @@ describe('replaceUrlParams', () => { }) describe('removeIndexString', () => { - it('Should remove last `index` string', () => { + it('Should remove last `/index` string', () => { let url = 'http://localhost/index' let newUrl = removeIndexString(url) - expect(newUrl).toBe('http://localhost/') + expect(newUrl).toBe('http://localhost') url = '/index' newUrl = removeIndexString(url) - expect(newUrl).toBe('/') + expect(newUrl).toBe('') url = '/sub/index' newUrl = removeIndexString(url) - expect(newUrl).toBe('/sub/') + expect(newUrl).toBe('/sub') url = '/subindex' newUrl = removeIndexString(url) diff --git a/src/client/utils.ts b/src/client/utils.ts index 0b2573fba..d46ce242f 100644 --- a/src/client/utils.ts +++ b/src/client/utils.ts @@ -16,7 +16,7 @@ export const replaceUrlParam = (urlString: string, params: Record { - return urlSting.replace(/\/index$/, '/') + return urlSting.replace(/\/index$/, '') } function isObject(item: unknown): item is ObjectType {