Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(core): add failing test to generatePath, see #6171 #6172

Merged
merged 4 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/react-router/modules/__tests__/generatePath-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,16 @@ describe("generatePath", () => {
expect(generated).toBe("/");
});
});

describe('simple pattern="/view/:id"', () => {
it("handle = on params", () => {
const pattern = "/view/:id";
const params = { id: "Q29tcGxhaW50OjVhZjFhMDg0MzhjMTk1MThiMTdlOTQ2Yg==" };

const generated = generatePath(pattern, params);
expect(generated).toBe(
"/view/Q29tcGxhaW50OjVhZjFhMDg0MzhjMTk1MThiMTdlOTQ2Yg=="
);
});
});
});
2 changes: 1 addition & 1 deletion packages/react-router/modules/generatePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const compileGenerator = pattern => {

if (cache[pattern]) return cache[pattern];

const compiledGenerator = pathToRegexp.compile(pattern);
const compiledGenerator = pathToRegexp.compile(pattern, { pretty: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty should be passed when calling the compiled function, not when creating it


if (cacheCount < cacheLimit) {
cache[pattern] = compiledGenerator;
Expand Down