UNPKG

498 BJavaScriptView Raw
1const utils = require('./utils');
2
3let defaultDepth = 3;
4const matchDepthParameter =
5 typeof window !== 'undefined' &&
6 typeof window.location !== 'undefined' &&
7 window.location.search.match(/[?&]depth=(\d+)(?:$|&)/);
8
9if (matchDepthParameter) {
10 defaultDepth = parseInt(matchDepthParameter[1], 10);
11} else {
12 const defaultDepthFromEnv = utils.getEnv('UNEXPECTED_DEPTH');
13 if (defaultDepthFromEnv) {
14 defaultDepth = parseInt(defaultDepthFromEnv, 10);
15 }
16}
17module.exports = defaultDepth;