UNPKG

4.67 kBSource Map (JSON)View Raw
1{
2 "version": 3,
3 "file": "pushStateLocationService.js",
4 "sourceRoot": "",
5 "sources": [
6 "@uirouter/core/vanilla/pushStateLocationService.ts"
7 ],
8 "names": [],
9 "mappings": ";;;;;;;;;;;;;;;;AACA,6DAA6D;AAC7D,oCAA8F;AAE9F;;;;GAIG;AACH;IAA8C,4CAAoB;IAGhE,kCAAY,MAAgB;QAA5B,YACE,kBAAM,MAAM,EAAE,IAAI,CAAC,SAGpB;QAFC,KAAI,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;QACxC,aAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;;IAC3D,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACK,iDAAc,GAAtB;QACE,OAAO,6BAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvD,CAAC;IAES,uCAAI,GAAd;QACM,IAAA,KAA6B,IAAI,CAAC,SAAS,EAAzC,QAAQ,cAAA,EAAE,IAAI,UAAA,EAAE,MAAM,YAAmB,CAAC;QAChD,MAAM,GAAG,mBAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB;QACnD,IAAI,GAAG,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB;QAE9C,IAAM,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACzC,IAAM,kBAAkB,GAAG,QAAQ,KAAK,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QAChE,IAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC;QAC5E,QAAQ,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,QA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import { LocationConfig, root, splitHash, splitQuery, stripLastPathElement } from '../common';\n\n/**\n * A `LocationServices` that gets/sets the current location using the browser's `location` and `history` apis\n *\n * Uses `history.pushState` and `history.replaceState`\n */\nexport class PushStateLocationService extends BaseLocationServices {\n _config: LocationConfig;\n\n constructor(router: UIRouter) {\n super(router, true);\n this._config = router.urlService.config;\n root.addEventListener('popstate', this._listener, false);\n }\n\n /**\n * Gets the base prefix without:\n * - trailing slash\n * - trailing filename\n * - protocol and hostname\n *\n * If <base href='/base/'>, this returns '/base'.\n * If <base href='/foo/base/'>, this returns '/foo/base'.\n * If <base href='/base/index.html'>, this returns '/base'.\n * If <base href='http://localhost:8080/base/index.html'>, this returns '/base'.\n * If <base href='/base'>, this returns ''.\n * If <base href='http://localhost:8080'>, this returns ''.\n * If <base href='http://localhost:8080/'>, this returns ''.\n *\n * See: https://html.spec.whatwg.org/dev/semantics.html#the-base-element\n */\n private _getBasePrefix() {\n return stripLastPathElement(this._config.baseHref());\n }\n\n protected _get() {\n let { pathname, hash, search } = this._location;\n search = splitQuery(search)[1]; // strip ? if found\n hash = splitHash(hash)[1]; // strip # if found\n\n const basePrefix = this._getBasePrefix();\n const exactBaseHrefMatch = pathname === this._config.baseHref();\n const startsWithBase = pathname.substr(0, basePrefix.length) === basePrefix;\n pathname = exactBaseHrefMatch ? '/' : startsWithBase ? pathname.substring(basePrefix.length) : pathname;\n\n return pathname + (search ? '?' + search : '') + (hash ? '#' + hash : '');\n }\n\n protected _set(state: any, title: string, url: string, replace: boolean) {\n const basePrefix = this._getBasePrefix();\n const slash = url && url[0] !== '/' ? '/' : '';\n const fullUrl = url === '' || url === '/' ? this._config.baseHref() : basePrefix + slash + url;\n\n if (replace) {\n this._history.replaceState(state, title, fullUrl);\n } else {\n this._history.pushState(state, title, fullUrl);\n }\n }\n\n public dispose(router: UIRouter) {\n super.dispose(router);\n root.removeEventListener('popstate', this._listener);\n }\n}\n"
12 ]
13}
\No newline at end of file