redux-promise-thunk
Version:
Thunk generator to dispatch Flux-Standard-Action in each phase of promise
34 lines (26 loc) • 841 B
JavaScript
import warning from 'warning';
import extractPath from './extractPath';
function parsePath(path) {
var pathname = extractPath(path);
var search = '';
var hash = '';
process.env.NODE_ENV !== 'production' ? warning(path === pathname, 'A path must be pathname + search + hash only, not a fully qualified URL like "%s"', path) : undefined;
var hashIndex = pathname.indexOf('#');
if (hashIndex !== -1) {
hash = pathname.substring(hashIndex);
pathname = pathname.substring(0, hashIndex);
}
var searchIndex = pathname.indexOf('?');
if (searchIndex !== -1) {
search = pathname.substring(searchIndex);
pathname = pathname.substring(0, searchIndex);
}
if (pathname === '') pathname = '/';
return {
pathname: pathname,
search: search,
hash: hash
};
}
export default parsePath;
;