diff --git a/deno_dist/client/utils.ts b/deno_dist/client/utils.ts index aea09122..51799361 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 a67a0140..32ddfe41 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 0b2573fb..d46ce242 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 {