Skip to content
Myr

Merge commit from fork

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by GitHub · parent adecab1 · Browse files · 2 files+10 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−6 removed

  • tests:+9 added−0 removed
  • other:+1 added−6 removed

2 files+10 added−6 removed

modified:src/utils/url.test.ts+9 added
114 unmodified lines
115 it('getPath - http+unix', () => {116 const path = getPath(new Request('http+unix://%2Ftmp%2Fsocket%2Esock/hello/'))117 expect(path).toBe('/hello/')118 })119120 it.each([121 'http:/example.com/hello', // invalid HTTP URL122 'http:///hello', // invalid HTTP URL123 'http://a/:/hello', // starts with `/:/`124 'x://a/:/hello', // unknown schema125 ])('getPath - %s', (url) => {126 expect(getPath(new Request(url))).toBe(new URL(url).pathname)127 })128 })129130 describe('getQueryStrings', () => {131 it('getQueryStrings', () => {
184 unmodified lines
modified:src/utils/url.ts+1 added-6 removed
103 unmodified lines
104const tryDecodeURI = (str: string) => tryDecode(str, decodeURI)105106export const getPath = (request: Request): string => {107 const url = request.url108 const start = url.indexOf(109 '/',110 url.charCodeAt(9) === 58111 ? 13 // http+unix://112 : 8 // http:// or https://113 )108 const start = url.indexOf('/', url.indexOf(':') + 4)109 let i = start110 for (; i < url.length; i++) {111 const charCode = url.charCodeAt(i)112 if (charCode === 37) {
195 unmodified lines