Skip to content

Commit a759887

Browse files
committed
Merge pull request #3054 from rackt/server-basename
Add back basename support in match()
2 parents 1a81557 + d4a925a commit a759887

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

modules/__tests__/serverRendering-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ describe('server rendering', function () {
152152
})
153153
})
154154

155+
it('accepts a basename option', function (done) {
156+
match({ routes, location: '/dashboard', basename: '/nasebame' }, function (error, redirectLocation, renderProps) {
157+
const string = renderToString(
158+
<RouterContext {...renderProps} />
159+
)
160+
expect(string).toMatch(/\/nasebame/)
161+
done()
162+
})
163+
})
164+
155165
describe('server/client consistency', function () {
156166
// Just render to static markup here to avoid having to normalize markup.
157167

modules/createMemoryHistory.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import useQueries from 'history/lib/useQueries'
2+
import useBasename from 'history/lib/useBasename'
23
import baseCreateMemoryHistory from 'history/lib/createMemoryHistory'
34

45
export default function createMemoryHistory(options) {
@@ -7,7 +8,7 @@ export default function createMemoryHistory(options) {
78
// `useQueries` doesn't understand the signature
89
const memoryHistory = baseCreateMemoryHistory(options)
910
const createHistory = () => memoryHistory
10-
const history = useQueries(createHistory)(options)
11+
const history = useQueries(useBasename(createHistory))(options)
1112
history.__v2_compatible__ = true
1213
return history
1314
}

0 commit comments

Comments
 (0)