seasonedcc / composable-functions

Types and functions to make composition easy and safe
MIT License
649 stars 13 forks source link

URIError: URI malformed #117

Closed ledniy closed 10 months ago

ledniy commented 10 months ago

Just faced the issue while tried to pass % symbol in some of the inputs.

error: URIError: URI malformed
      const value = decodeURIComponent(encodedValue)
                    ^
    at decodeURIComponent (<anonymous>)
    at file:///Users/ledniy/Dev/domain-functions/src/input-resolvers.ts:33:21
    at Array.reduce (<anonymous>)
    at inputFromSearch (file:///Users/ledniy/Dev/domain-functions/src/input-resolvers.ts:31:6)
    at inputFromFormData (file:///Users/ledniy/Dev/domain-functions/src/input-resolvers.ts:114:3)
    at Module.inputFromForm (file:///Users/ledniy/Dev/domain-functions/src/input-resolvers.ts:132:3)
    at async Object.<anonymous> (file:///Users/ledniy/Dev/domain-functions/src/input-resolvers.test.ts:68:18)
    at async Function.runTest (https://deno.land/std@0.198.0/testing/_test_suite.ts:358:7)
    at async Function.runTest (https://deno.land/std@0.198.0/testing/_test_suite.ts:346:9)
    at async fn (https://deno.land/std@0.198.0/testing/_test_suite.ts:316:13)

Can be reproduced with following test:

  it('should parse all symbols correctly', async () => {
    const request = makePost([
      ['formula', '3 % 2']
    ])
    assertEquals(await subject.inputFromForm(request), {
      formula: '3 % 2'
    })
  })
gustavoguichard commented 10 months ago

Hey @ledniy, Thank you for reporting! It doesn't surprise me that it failed but I'll try to investigate it soon and see if we can come up with a fix.

diogob commented 10 months ago

@ledniy thanks for the test case

gustavoguichard commented 10 months ago

Hey @ledniy , this is now fixed in v2.5.1 .