Skip to content

URLs with encoded characters #26

@jjuutila

Description

@jjuutila

I would like to hear your thoughts how to solve a problem with percent encoded characters in an URL. The following example illustrates what I'm trying to get working:

const RouteNode = require('route-node')

const rootNode = new RouteNode('', '', [{
  name: 'product-page',
  path: '/:productName<.+>/:productId<(\\w{2}[0-9]{4})>.html'
}])

const matchedPath = rootNode.matchPath('/something-%21-%23-%24-%25-/B41680.html')
console.log('matchedPath', matchedPath)

rootNode.matchPath returns null because segment has an encoded value and consumedPath has the same value but it is decoded (it is decoded in path-parser). See the code here: https://github.com/troch/route-node/blob/master/modules/matchChildren.ts#L64

Do you think I should just do decodeURIComponent(segment)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions