From d4a925a2569d9d1c9669ec2a64e8b7006be9e1ad Mon Sep 17 00:00:00 2001 From: Tim Dorr Date: Tue, 9 Feb 2016 19:35:08 -0500 Subject: [PATCH] Add back basename support in match() --- modules/__tests__/serverRendering-test.js | 10 ++++++++++ modules/createMemoryHistory.js | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/__tests__/serverRendering-test.js b/modules/__tests__/serverRendering-test.js index a1aabb3f20..55360b0c48 100644 --- a/modules/__tests__/serverRendering-test.js +++ b/modules/__tests__/serverRendering-test.js @@ -152,6 +152,16 @@ describe('server rendering', function () { }) }) + it('accepts a basename option', function (done) { + match({ routes, location: '/dashboard', basename: '/nasebame' }, function (error, redirectLocation, renderProps) { + const string = renderToString( + + ) + expect(string).toMatch(/\/nasebame/) + done() + }) + }) + describe('server/client consistency', function () { // Just render to static markup here to avoid having to normalize markup. diff --git a/modules/createMemoryHistory.js b/modules/createMemoryHistory.js index d26f411e53..ff8ef2a447 100644 --- a/modules/createMemoryHistory.js +++ b/modules/createMemoryHistory.js @@ -1,4 +1,5 @@ import useQueries from 'history/lib/useQueries' +import useBasename from 'history/lib/useBasename' import baseCreateMemoryHistory from 'history/lib/createMemoryHistory' export default function createMemoryHistory(options) { @@ -7,7 +8,7 @@ export default function createMemoryHistory(options) { // `useQueries` doesn't understand the signature const memoryHistory = baseCreateMemoryHistory(options) const createHistory = () => memoryHistory - const history = useQueries(createHistory)(options) + const history = useQueries(useBasename(createHistory))(options) history.__v2_compatible__ = true return history }