diff --git a/package.json b/package.json index 26e75d1b2..3c1481124 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "syso", "license": "MIT", - "version": "0.7.0", + "version": "1.2.1", "description": "Library to compute the french social security contributions. Also a website that explains the calculations, and a generic engine to build cool forms that asks the question needed to compute an objective.", "main": "./dist/engine.js", "files": [ @@ -81,7 +81,7 @@ "test": "yarn test-common", "test-one": "yarn mocha-webpack --webpack-config source/webpack.test.js --require source-map-support/register --include componentTestSetup.js --require mock-local-storage --require test/helpers/browser.js", "test-components": "mocha-webpack --webpack-config source/webpack.test.js --require source-map-support/register --include componentTestSetup.js --require mock-local-storage ---require test/helpers/browser.js \"source/components/**/*.test.js\" --watch", - "test-lib": "yarn test-common --grep 'library'", + "test-lib": "mocha-webpack --webpack-config source/webpack.lib.js --require source-map-support/register --include componentTestSetup.js --require mock-local-storage test/library.test.js", "test-expressions": "yarn test-common --grep 'Suite expressions'", "test-units": "mocha-webpack --webpack-config source/webpack.test.js --require source-map-support/register --include componentTestSetup.js --require mock-local-storage --require test/helpers/browser.js test/units.test.js", "compile-lib": "yarn webpack --config source/webpack.lib.js", @@ -133,7 +133,7 @@ "http-server": "^0.11.1", "intl": "^1.2.5", "intl-locales-supported": "^1.0.0", - "isomorphic-style-loader": "^4.0.0", + "isomorphic-style-loader": "^5.1.0", "jsdom": "^12.0.0", "json-loader": "^0.5.7", "koa-connect": "^2.0.1", diff --git a/source/Tracker.js b/source/Tracker.js index f583e13ee..bcda6793a 100644 --- a/source/Tracker.js +++ b/source/Tracker.js @@ -15,7 +15,7 @@ export default class Tracker { previousPath: string constructor(pushFunction: PushType = args => window._paq.push(args)) { - window._paq = window._paq || [] + if (typeof window !== 'undefined') window._paq = window._paq || [] this.push = debounce(200, pushFunction) } diff --git a/source/i18n.js b/source/i18n.js index 412e17b6d..a08de02b6 100644 --- a/source/i18n.js +++ b/source/i18n.js @@ -11,7 +11,8 @@ import { let lang = getIframeOption('lang') || - queryString.parse(location.search)['lang'] || + (typeof location !== 'undefined' && + queryString.parse(location.search)['lang']) || parseDataAttributes(getFromSessionStorage('lang')) || 'fr' diff --git a/source/utils.js b/source/utils.js index 5697fd24a..cbc0c1564 100644 --- a/source/utils.js +++ b/source/utils.js @@ -3,7 +3,8 @@ import { map } from 'ramda' export let capitalise0 = (name: string) => name[0].toUpperCase() + name.slice(1) -export let getUrl = () => window.location.href.toString() +export let getUrl = () => + typeof window !== 'undefined' ? window.location.href.toString() : null export let parseDataAttributes = (value: any) => value === 'undefined' @@ -17,7 +18,7 @@ export let parseDataAttributes = (value: any) => export let getIframeOption = (optionName: string) => { let url = getUrl(), - hasOption = url.includes(optionName + '=') + hasOption = url?.includes(optionName + '=') return parseDataAttributes( hasOption && url.split(optionName + '=')[1].split('&')[0] ) diff --git a/yarn.lock b/yarn.lock index 7b37e251a..eb6979f0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1738,7 +1738,7 @@ babel-plugin-webpack-alias@^2.1.2: lodash.some "^4.5.1" lodash.template "^4.3.0" -babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.25.0, babel-runtime@^6.26.0: +babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= @@ -4681,12 +4681,7 @@ hoek@4.x.x: resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb" integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA== -hoist-non-react-statics@^2.2.2: - version "2.5.5" - resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47" - integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw== - -hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b" integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA== @@ -5415,15 +5410,14 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= -isomorphic-style-loader@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/isomorphic-style-loader/-/isomorphic-style-loader-4.0.0.tgz#0d8faa12885e2830918c54815042c0e3b55dc38d" - integrity sha512-F+Sd5jnVbDLhd23c+ksYTj0TZztfCnF0hOZMVKy8ZUX+vVuFSYiNITWKifT8/odTlyRAVmQxO1Yl3CGf+jHKqw== +isomorphic-style-loader@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/isomorphic-style-loader/-/isomorphic-style-loader-5.1.0.tgz#4845f90bb9828f3dfecc82d0574c9ed01bbaba2d" + integrity sha512-6KBucdRvmz5U5SMrdDUhDyTQ6nRmCjzjopJBDVkfx1+xsoiyNYVlcY1OqSH1SHKYRzVWhqWXIBGgeTl5L7gViw== dependencies: - babel-runtime "^6.25.0" - hoist-non-react-statics "^2.2.2" - loader-utils "^1.1.0" - prop-types "^15.5.10" + hoist-non-react-statics "^3.0.0" + loader-utils "^1.2.3" + react "^16.3.0" isstream@~0.1.2: version "0.1.2" @@ -8090,7 +8084,7 @@ react-virtualized@^9.0.0, react-virtualized@^9.20.0: prop-types "^15.6.0" react-lifecycles-compat "^3.0.4" -react@^16.8.6: +react@^16.3.0, react@^16.8.6: version "16.9.0" resolved "https://registry.yarnpkg.com/react/-/react-16.9.0.tgz#40ba2f9af13bc1a38d75dbf2f4359a5185c4f7aa" integrity sha512-+7LQnFBwkiw+BobzOF6N//BdoNw0ouwmSJTEm9cglOOmsg/TMiFHZLe2sEoN5M7LgJTj9oHH0gxklfnQe66S1w==