From 53507e70c5cdb7531fe2e6899813da3f9e9d07d2 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 21 Dec 2015 14:57:13 -0800 Subject: [PATCH 1/2] Remove history from dependencies and perform a sanity check on the history API --- package.json | 3 +-- src/reduxReactRouter.js | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ff4da87..0e744c0 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "webpack": "^1.12.1" }, "dependencies": { - "deep-equal": "^1.0.1", - "history": "^1.12.0" + "deep-equal": "^1.0.1" } } diff --git a/src/reduxReactRouter.js b/src/reduxReactRouter.js index 10150c0..09cd948 100644 --- a/src/reduxReactRouter.js +++ b/src/reduxReactRouter.js @@ -25,6 +25,14 @@ export default function reduxReactRouter({ stringifyQuery }); + [ 'pushState', 'push', 'replaceState', 'replace', + 'setState', 'go', 'goBack', 'goForward', + 'listen', 'createLocation', 'match' ].forEach(funcName => { + if (!history.hasOwnProperty(funcName)) { + throw new Error(`History API does not support function: ${funcName}`); + } + }); + const store = applyMiddleware( historyMiddleware(history) From 0cdf254cfa8b71801f70ff5d597164003e5bdb06 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 21 Dec 2015 15:01:00 -0800 Subject: [PATCH 2/2] Check if function type as well --- src/reduxReactRouter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/reduxReactRouter.js b/src/reduxReactRouter.js index 09cd948..0804764 100644 --- a/src/reduxReactRouter.js +++ b/src/reduxReactRouter.js @@ -28,7 +28,8 @@ export default function reduxReactRouter({ [ 'pushState', 'push', 'replaceState', 'replace', 'setState', 'go', 'goBack', 'goForward', 'listen', 'createLocation', 'match' ].forEach(funcName => { - if (!history.hasOwnProperty(funcName)) { + if (!history.hasOwnProperty(funcName) && + typeof(history[funcName]) === 'function') { throw new Error(`History API does not support function: ${funcName}`); } });