Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should not allow to accept void', () => {
// $ExpectError
const location = parsePath()
const state: {} = location
});
});
it('should allow to use string argument', () => {
const location = parsePath('/test?query#hash')
const state: {} = location
// $ExpectError
const key: string = location
});
function serveIndexWithRouting (req, res, next) {
const envRequire = isProduction ? require : require('import-fresh')
const template = envRequire(indexWithRouting)
const routes = template.routes
const location = parsePath(req.url)
return Promise.resolve(routes)
.then(routes => (routes && routes.match(location, req)) || { status: 200, data: null })
.then(({ status, headers, data }) =>
Promise.resolve(template({ location, data })).then(html => [status, headers, html])
)
.then(([ status, headers, html ]) => res.status(status).set(headers).send(html))
}
function createLocation(location) {
return typeof location === 'string' ? parsePath(location) : normalizeLocation(location);
}
function createDispatchAction(dispatchFuncName, pathAndQuery, params, options) {
invariant(typeof pathAndQuery === 'string', 'pathAnyQuery expects a string');
const { actionNames, routes, routeComponentPropNames } = options;
return RouteDispatcher[dispatchFuncName](
parsePath(pathAndQuery),
actionNames,
{ routes, routeComponentPropNames },
Object.assign({}, params));
}