delvedor / find-my-way

A crazy fast HTTP router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Route does not match when the parameter value is long

petr-pokorny-1 opened this issue · comments

The following test fails when the paramValue is a long string.
Am I doing something wrong?

    it('longParameter', done => {
        // this works
        //const paramValue = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";

        // this does not work (route not matched)
        const paramValue = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";

        const fileName = "file";
        const url = `/segment1/${paramValue}/${fileName}.ext`;
        findMyWay.on('GET', "/segment1/:param/:fileName.ext", (req, res, params) => {
            expect(params.param).toEqual(paramValue);
            expect(params.fileName).toEqual(fileName);
            done();
        })
        try {
            findMyWay.lookup({method: 'GET', url: url, headers: {}}, null);
        } catch (e) {
            done(e);
        }
    });

From docs:

You can set a custom length for parameters in parametric (standard, regex and multi) routes by using maxParamLength option, the default value is 100 characters.
If the maximum length limit is reached, the default route will be invoked.

@Eomm I see. Thank you for your help. sorry for the noise.