Skip to content

Commit

Permalink
Add back basename support in match()
Browse files Browse the repository at this point in the history
  • Loading branch information
timdorr committed Feb 10, 2016
1 parent 1a81557 commit d4a925a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions modules/__tests__/serverRendering-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<RouterContext {...renderProps} />
)
expect(string).toMatch(/\/nasebame/)
done()
})
})

describe('server/client consistency', function () {
// Just render to static markup here to avoid having to normalize markup.

Expand Down
3 changes: 2 additions & 1 deletion modules/createMemoryHistory.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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
}

1 comment on commit d4a925a

@fiowind
Copy link

Choose a reason for hiding this comment

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

whether you forget to import createHistory, it will be warned in the history of 2.1.2

Please sign in to comment.