UNPKG

ember-source

Version:

A JavaScript framework for creating ambitious web applications

49 lines (40 loc) 944 B
/** @private Returns the current `location.pathname`, ensuring it has a leading slash. */ function getPath(location) { let pathname = location.pathname; if (pathname[0] !== '/') { pathname = `/${pathname}`; } return pathname; } /** @private Returns the current `location.search`. */ function getQuery(location) { return location.search; } /** @private Returns the hash or empty string */ function getHash(location) { if (location.hash !== undefined) { return location.hash.substring(0); } return ''; } function getFullPath(location) { return getPath(location) + getQuery(location) + getHash(location); } /** Replaces the current location, making sure we explicitly include the origin to prevent redirecting to a different origin. @private */ function replacePath(location, path) { location.replace(location.origin + path); } export { getFullPath, getHash, getPath, getQuery, replacePath };