diff --git a/deno_dist/router/pattern-router/router.ts b/deno_dist/router/pattern-router/router.ts index e7d0d60d..bdd1a66e 100644 --- a/deno_dist/router/pattern-router/router.ts +++ b/deno_dist/router/pattern-router/router.ts @@ -8,7 +8,7 @@ export class PatternRouter implements Router { private dNames: Record = {} // Short name of duplicatedNames add(method: string, path: string, handler: T) { - const endsWithWildcard = path.endsWith('*') + const endsWithWildcard = path[path.length - 1] === '*' if (endsWithWildcard) { path = path.slice(0, -2) } diff --git a/deno_dist/utils/url.ts b/deno_dist/utils/url.ts index c1827406..a6ae93c6 100644 --- a/deno_dist/utils/url.ts +++ b/deno_dist/utils/url.ts @@ -87,13 +87,13 @@ export const mergePath = (...paths: string[]): string => { for (let path of paths) { /* ['/hey/','/say'] => ['/hey', '/say'] */ - if (p.endsWith('/')) { + if (p[p.length - 1] === '/') { p = p.slice(0, -1) endsWithSlash = true } /* ['/hey','say'] => ['/hey', '/say'] */ - if (!path.startsWith('/')) { + if (path[0] !== '/') { path = `/${path}` } diff --git a/src/router/pattern-router/router.ts b/src/router/pattern-router/router.ts index 0d0cf62b..edecd74c 100644 --- a/src/router/pattern-router/router.ts +++ b/src/router/pattern-router/router.ts @@ -8,7 +8,7 @@ export class PatternRouter implements Router { private dNames: Record = {} // Short name of duplicatedNames add(method: string, path: string, handler: T) { - const endsWithWildcard = path.endsWith('*') + const endsWithWildcard = path[path.length - 1] === '*' if (endsWithWildcard) { path = path.slice(0, -2) } diff --git a/src/utils/url.ts b/src/utils/url.ts index c1827406..a6ae93c6 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -87,13 +87,13 @@ export const mergePath = (...paths: string[]): string => { for (let path of paths) { /* ['/hey/','/say'] => ['/hey', '/say'] */ - if (p.endsWith('/')) { + if (p[p.length - 1] === '/') { p = p.slice(0, -1) endsWithSlash = true } /* ['/hey','say'] => ['/hey', '/say'] */ - if (!path.startsWith('/')) { + if (path[0] !== '/') { path = `/${path}` }