troch / path-parser

A small utility to parse paths.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Case insensitive query parameters names

michaeluskov opened this issue · comments

Hello everyone!

At first, thank you for that library.

Is there any way to make path-parser treat query parameters in the case-insensitive way?

import Path from 'path-parser';

const path = new Path('/users?offset&limit');
document.write(JSON.stringify(path.test('/users?limIt=15')));
document.write("<br>");
document.write(JSON.stringify(path.test('/users?limIt=15', { caseSensitive: false })));

Will write

null
null

(example)

But I want to get {limit: '15'}.
How can I do it?

Hello, currently the case sensitive functionality is not on parameter names and values, but on the static part of a defined URL. Not something I have the time to commit to right now, but you're welcome to raise a PR for it.