Skip to content
Myr

Move util method to util.js

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

authored by Yusuke Wada · committed by Yusuke Wada · parent 28663ea · Browse files · 3 files+25 added−8 removed
This commit

State

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

Diff stats

3 files+25 added−8 removed

  • tests:+16 added−1 removed
  • other:+9 added−7 removed

3 files+25 added−8 removed

modified:src/hono.js+2 added-7 removed
modified:src/util.js+7 added
modified:src/util.test.js+16 added-1 removed
1const { splitPath, getPattern } = require('./util')1const { splitPath, getPattern, getPathFromURL } = require('./util')23describe('Utility methods', () => {4 it('splitPath', () => {5 let ps = splitPath('/')
19 unmodified lines
25 res = getPattern(':id{[0-9]+}')26 expect(res[0]).toBe('id')27 expect(res[1]).toBe('([0-9]+)')28 })2930 it('getPathFromURL', () => {31 let path = getPathFromURL('https://example.com/')32 expect(path).toBe('/')33 path = getPathFromURL('https://example.com/hello')34 expect(path).toBe('/hello')35 path = getPathFromURL('https://example.com/hello/hey')36 expect(path).toBe('/hello/hey')37 path = getPathFromURL('https://example.com/hello?name=foo')38 expect(path).toBe('/hello')39 path = getPathFromURL('https://example.com/hello/hey?name=foo&name=bar')40 expect(path).toBe('/hello/hey')41 path = getPathFromURL('https://example.com/hello/hey#fragment')42 expect(path).toBe('/hello/hey')43 })44})