* @ngdoc provider * @name $locationProvider * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.
()
| 11897 | * Use the `$locationProvider` to configure how the application deep linking paths are stored. |
| 11898 | */ |
| 11899 | function $LocationProvider() { |
| 11900 | var hashPrefix = '', |
| 11901 | html5Mode = { |
| 11902 | enabled: false, |
| 11903 | requireBase: true, |
| 11904 | rewriteLinks: true |
| 11905 | }; |
| 11906 | |
| 11907 | /** |
| 11908 | * @ngdoc method |
| 11909 | * @name $locationProvider#hashPrefix |
| 11910 | * @description |
| 11911 | * @param {string=} prefix Prefix for hash part (containing path and search) |
| 11912 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 11913 | */ |
| 11914 | this.hashPrefix = function(prefix) { |
| 11915 | if (isDefined(prefix)) { |
| 11916 | hashPrefix = prefix; |
| 11917 | return this; |
| 11918 | } else { |
| 11919 | return hashPrefix; |
| 11920 | } |
| 11921 | }; |
| 11922 | |
| 11923 | /** |
| 11924 | * @ngdoc method |
| 11925 | * @name $locationProvider#html5Mode |
| 11926 | * @description |
| 11927 | * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. |
| 11928 | * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported |
| 11929 | * properties: |
| 11930 | * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to |
| 11931 | * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not |
| 11932 | * support `pushState`. |
| 11933 | * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies |
| 11934 | * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are |
| 11935 | * true, and a base tag is not present, an error will be thrown when `$location` is injected. |
| 11936 | * See the {@link guide/$location $location guide for more information} |
| 11937 | * - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled, |
| 11938 | * enables/disables url rewriting for relative links. |
| 11939 | * |
| 11940 | * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter |
| 11941 | */ |
| 11942 | this.html5Mode = function(mode) { |
| 11943 | if (isBoolean(mode)) { |
| 11944 | html5Mode.enabled = mode; |
| 11945 | return this; |
| 11946 | } else if (isObject(mode)) { |
| 11947 | |
| 11948 | if (isBoolean(mode.enabled)) { |
| 11949 | html5Mode.enabled = mode.enabled; |
| 11950 | } |
| 11951 | |
| 11952 | if (isBoolean(mode.requireBase)) { |
| 11953 | html5Mode.requireBase = mode.requireBase; |
| 11954 | } |
| 11955 | |
| 11956 | if (isBoolean(mode.rewriteLinks)) { |
nothing calls this directly
no test coverage detected