summaryrefslogtreecommitdiffstats
path: root/js/vendor/angular-ui-router
diff options
context:
space:
mode:
authorHendrik Leppelsack <hendrik@leppelsack.de>2016-02-11 15:30:52 +0100
committerHendrik Leppelsack <hendrik@leppelsack.de>2016-02-11 16:11:13 +0100
commite18c6d794de6faea6ee87959e8cd923080cd3bb0 (patch)
treea8f1d3ef0d31df57b9b703215b60a0b2aee1342e /js/vendor/angular-ui-router
parent19f6e89aa11667e402880635bda73164922eaaf6 (diff)
show delete immediately
Diffstat (limited to 'js/vendor/angular-ui-router')
-rw-r--r--js/vendor/angular-ui-router/.bower.json12
-rw-r--r--js/vendor/angular-ui-router/CHANGELOG.md69
-rw-r--r--js/vendor/angular-ui-router/CONTRIBUTING.md10
-rw-r--r--js/vendor/angular-ui-router/README.md2
-rw-r--r--js/vendor/angular-ui-router/api/angular-ui-router.d.ts126
-rw-r--r--js/vendor/angular-ui-router/bower.json3
-rw-r--r--js/vendor/angular-ui-router/release/angular-ui-router.js511
-rw-r--r--js/vendor/angular-ui-router/release/angular-ui-router.min.js5
-rw-r--r--js/vendor/angular-ui-router/src/common.js5
-rw-r--r--js/vendor/angular-ui-router/src/state.js34
-rw-r--r--js/vendor/angular-ui-router/src/stateDirectives.js294
-rw-r--r--js/vendor/angular-ui-router/src/stateFilters.js8
-rw-r--r--js/vendor/angular-ui-router/src/urlMatcherFactory.js57
-rw-r--r--js/vendor/angular-ui-router/src/urlRouter.js22
-rw-r--r--js/vendor/angular-ui-router/src/view.js26
-rw-r--r--js/vendor/angular-ui-router/src/viewDirective.js65
16 files changed, 754 insertions, 495 deletions
diff --git a/js/vendor/angular-ui-router/.bower.json b/js/vendor/angular-ui-router/.bower.json
index d4d0fa46..d8645c9d 100644
--- a/js/vendor/angular-ui-router/.bower.json
+++ b/js/vendor/angular-ui-router/.bower.json
@@ -1,6 +1,7 @@
{
"name": "angular-ui-router",
- "version": "0.2.15",
+ "version": "0.2.17",
+ "license": "MIT",
"main": "./release/angular-ui-router.js",
"dependencies": {
"angular": ">= 1.0.8"
@@ -21,14 +22,13 @@
"files.js"
],
"homepage": "https://github.com/angular-ui/ui-router",
- "_release": "0.2.15",
+ "_release": "0.2.17",
"_resolution": {
"type": "version",
- "tag": "0.2.15",
- "commit": "805e69bae319e922e4d3265b7ef565058aaff850"
+ "tag": "0.2.17",
+ "commit": "87f10dfc9c4b0420ae6128bb46499deb75f3e705"
},
"_source": "git://github.com/angular-ui/ui-router.git",
"_target": "~0.2.15",
- "_originalSource": "angular-ui-router",
- "_direct": true
+ "_originalSource": "angular-ui-router"
} \ No newline at end of file
diff --git a/js/vendor/angular-ui-router/CHANGELOG.md b/js/vendor/angular-ui-router/CHANGELOG.md
index 23b59d3a..fb56d561 100644
--- a/js/vendor/angular-ui-router/CHANGELOG.md
+++ b/js/vendor/angular-ui-router/CHANGELOG.md
@@ -1,3 +1,72 @@
+<a name="0.2.17"></a>
+### 0.2.17 (2016-01-25)
+
+
+#### Bug Fixes
+
+* **uiSrefActive:** allow multiple classes ([a89114a0](https://github.com/angular-ui/ui-router/commit/a89114a083813c1a7280c48fc18e626caa5a31f4), closes [#2481](https://github.com/angular-ui/ui-router/issues/2481), [#2482](https://github.com/angular-ui/ui-router/issues/2482))
+
+
+<a name="0.2.16"></a>
+### 0.2.16 (2016-01-24)
+
+
+#### Bug Fixes
+
+* **$state:**
+ * statechangeCancel: Avoid infinite digest in .otherwise/redirect case. Don't clobber url if a new transition has started. Closes #222 ([e00aa695](https://github.com/angular-ui/ui-router/commit/e00aa695e41ddc5ebd5d2b226aa0917a751b11aa), closes [#2238](https://github.com/angular-ui/ui-router/issues/2238))
+ * transitionTo: Allow hash (#) value to be read as toParams['#'] in events. Re-add the saved hash before broadcasting $stateChangeStart event. ([8c1bf30d](https://github.com/angular-ui/ui-router/commit/8c1bf30d2a3b78ba40b330f12d854c885d6cc117))
+* **$stateParams:** Fix for testing: reset service instance between tests ([2aeb0c4b](https://github.com/angular-ui/ui-router/commit/2aeb0c4b205baf6cfa2ef25bb986bb160dc13bf9))
+* **$urlRouter:**
+ * Sort URL rules by specificity. Potential minor BC if apps were relying on rule registration order. ([b5c57c8e](https://github.com/angular-ui/ui-router/commit/b5c57c8ec2e14e17e75104c1424654f126ea4011))
+ * Use $sniffer for pushstate compat check ([c219e801](https://github.com/angular-ui/ui-router/commit/c219e801797f340ef9c5c919ab890ef003a7a042))
+* **UrlMatcher:**
+ * Properly encode/decode slashes in parameters Closes #2172 Closes #2250 Closes #1 ([02e98660](https://github.com/angular-ui/ui-router/commit/02e98660a80dfd1ca4b113dd24ee304af91e9f8c), closes [#2339](https://github.com/angular-ui/ui-router/issues/2339))
+ * Array types: Fix default value for array query parameters. Pass empty arrays through in handler. ([20d6e243](https://github.com/angular-ui/ui-router/commit/20d6e243f1745ddbf257217245a1dc22eabe13da), closes [#2222](https://github.com/angular-ui/ui-router/issues/2222))
+ * Remove trailing slash, if parameter is optional and was squashed from URL ([77fa11bf](https://github.com/angular-ui/ui-router/commit/77fa11bf0787d0f6da97ab0003ab29afb7411391), closes [#1902](https://github.com/angular-ui/ui-router/issues/1902))
+ * Allow a parameter declaration to configure the parameter type by name. closes #2294 ([e4010249](https://github.com/angular-ui/ui-router/commit/e40102492d40fe1cf6ba14d955fcc9f345c16458))
+ * include the slash when recognizing squashed params in url ([b5130bb1](https://github.com/angular-ui/ui-router/commit/b5130bb1215e15f832ea6daa670410b9a950c0d4), closes [#2064](https://github.com/angular-ui/ui-router/issues/2064))
+ * Allow url query param names to contain periods ([d31b3337](https://github.com/angular-ui/ui-router/commit/d31b3337cc2ce71d87c92fdded629e46558d0b49))
+* **reloadOnSearch:** Update `locals.globals.$stateParams` when reloadOnSearch=false ([350d3e87](https://github.com/angular-ui/ui-router/commit/350d3e87783a2263fd7d23913da34f1268c3300b), closes [#2356](https://github.com/angular-ui/ui-router/issues/2356))
+* **ui-view:**
+ * fix $animate usage for ng 1.4+ ([9b6d9a2d](https://github.com/angular-ui/ui-router/commit/9b6d9a2d0ce4ae08384165cb517bddea59b67892))
+ * change $viewContentLoading to pair with $viewContentLoaded ([f9b43d66](https://github.com/angular-ui/ui-router/commit/f9b43d66833f0e17de41fd8d1cc3b491e3ba4a0e), closes [#685](https://github.com/angular-ui/ui-router/issues/685))
+ * $destroy event is triggered before animation ends ([1be13795](https://github.com/angular-ui/ui-router/commit/1be13795686ab78abb2d5094bc8addcacb928975))
+* **uiSref:**
+ * Ensure URL once param checks pass ([9dc31c54](https://github.com/angular-ui/ui-router/commit/9dc31c5465328e5666468b0c2319ce205f4b72f8), closes [#2091](https://github.com/angular-ui/ui-router/issues/2091))
+ * uiSrefActive: update the active classes after linking directive ([7c914030](https://github.com/angular-ui/ui-router/commit/7c914030f13e05e45a941c1b723cb785db729890))
+
+
+#### Features
+
+* **$IncludedByStateFilter:** add parameters to $IncludedByStateFilter ([963f6e71](https://github.com/angular-ui/ui-router/commit/963f6e71633b9c3a266f3991d79089b7d14786b4), closes [#1735](https://github.com/angular-ui/ui-router/issues/1735))
+* **isStateFilter:** Include optional state params. ([71d74699](https://github.com/angular-ui/ui-router/commit/71d7469987ee9ca86a41c8c6393ccd5d8913c3d6))
+* **$state:** make state data inheritance prototypical ([c4fec8c7](https://github.com/angular-ui/ui-router/commit/c4fec8c7998113902af4152d716c42dada6eb465))
+* **$stateChangeStart:** Add options to event ([a1f07559](https://github.com/angular-ui/ui-router/commit/a1f07559ec74e10ff80bc4be81f287e3772b8fcb))
+* **UrlMatcher:** Add param only type names ([6a371f9b](https://github.com/angular-ui/ui-router/commit/6a371f9b70e37a82eb324122879e4473c3f6d526))
+* **uiSrefActive:**
+ * provide a ng-{class,style} like interface ([a9ff6feb](https://github.com/angular-ui/ui-router/commit/a9ff6febb469e0d5cd49054216c4472df7a6259d))
+ * allow active & active-eq on same element ([d9a676ba](https://github.com/angular-ui/ui-router/commit/d9a676ba2c4d9e954be224c60496bcb38f6074e3))
+* **uiState:** add ui-state directive ([3831af1d](https://github.com/angular-ui/ui-router/commit/3831af1dc71b601351e6694af0665a77297f8f7f), closes [#395](https://github.com/angular-ui/ui-router/issues/395), [#900](https://github.com/angular-ui/ui-router/issues/900), [#1932](https://github.com/angular-ui/ui-router/issues/1932))
+* **urlMatcher:** add support for optional spaces in params ([4b7f3046](https://github.com/angular-ui/ui-router/commit/4b7f304617f0b3590b532103b5c2fb526c98a9e4))
+
+
+<a name="0.2.15"></a>
+### 0.2.15 (2015-05-19)
+
+
+#### Bug Fixes
+
+* **$state:** reloadOnSearch should not affect non-search param changes. ([6ca0d770](https://github.com/angular-ui/ui-router/commit/6ca0d7704cf7de9c6e6b7bb64df2f9c68fe081cc), closes [#1079](https://github.com/angular-ui/ui-router/issues/1079))
+* **urlMatcherFactory:** Revert to 0.2.13 behavior where all string parameters are considered optional fi ([495a02c3](https://github.com/angular-ui/ui-router/commit/495a02c3cbde501c1c149bce137806669209bc29), closes [#1963](https://github.com/angular-ui/ui-router/issues/1963))
+* **urlRouter:** allow .when() to redirect, even after a successful $state.go() - This partially ([48aeaff6](https://github.com/angular-ui/ui-router/commit/48aeaff645baf3f42f5a8940ebd97563791ad9f8), closes [#1584](https://github.com/angular-ui/ui-router/issues/1584))
+
+
+#### Features
+
+* **$state:** Inject templateProvider with resolved values ([afa20f22](https://github.com/angular-ui/ui-router/commit/afa20f22373b7176b26daa7e1099750c4254a354))
+
+
<a name="0.2.14"></a>
### 0.2.14 (2015-04-23)
diff --git a/js/vendor/angular-ui-router/CONTRIBUTING.md b/js/vendor/angular-ui-router/CONTRIBUTING.md
index 63829a54..7e4fcb83 100644
--- a/js/vendor/angular-ui-router/CONTRIBUTING.md
+++ b/js/vendor/angular-ui-router/CONTRIBUTING.md
@@ -23,11 +23,11 @@ Issues only! |
Please keep in mind that the issue tracker is for *issues*. Please do *not* post an issue if you need help or support. Instead, see one of the above-mentioned forums or [IRC](irc://irc.freenode.net/#angularjs). |
####Purple Labels
-A purple label means that **you** need to take some further action.
- - ![Not Actionable - Need Info](http://angular-ui.github.io/ui-router/images/notactionable.png): Your issue is not specific enough, or there is no clear action that we can take. Please clarify and refine your issue.
- - ![Plunkr Please](http://angular-ui.github.io/ui-router/images/plunkrplease.png): Please [create a plunkr](http://bit.ly/UIR-Plunk)
- - ![StackOverflow](http://angular-ui.github.io/ui-router/images/stackoverflow.png): We suspect your issue is really a help request, or could be answered by the community. Please ask your question on [StackOverflow](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router). If you determine that is an actual issue, please explain why.
-
+A purple label means that **you** need to take some further action.
+ - ![Not Actionable - Need Info](ngdoc_assets/incomplete.png): Your issue is not specific enough, or there is no clear action that we can take. Please clarify and refine your issue.
+ - ![Plunkr Please](ngdoc_assets/example.png): Please [create a plunkr](http://bit.ly/UIR-Plunk)
+ - ![StackOverflow](ngdoc_assets/so.png): We suspect your issue is really a help request, or could be answered by the community. Please ask your question on [StackOverflow](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router). If you determine that is an actual issue, please explain why.
+
If your issue gets labeled with purple label, no further action will be taken until you respond to the label appropriately.
# Contribute
diff --git a/js/vendor/angular-ui-router/README.md b/js/vendor/angular-ui-router/README.md
index 1d8bcd61..7dcca4ce 100644
--- a/js/vendor/angular-ui-router/README.md
+++ b/js/vendor/angular-ui-router/README.md
@@ -2,7 +2,7 @@
#### The de-facto solution to flexible routing with nested views
---
-**[Download 0.2.15](http://angular-ui.github.io/ui-router/release/angular-ui-router.js)** (or **[Minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)**) **|**
+**[Download 0.2.17](http://angular-ui.github.io/ui-router/release/angular-ui-router.js)** (or **[Minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)**) **|**
**[Guide](https://github.com/angular-ui/ui-router/wiki) |**
**[API](http://angular-ui.github.io/ui-router/site) |**
**[Sample](http://angular-ui.github.com/ui-router/sample/) ([Src](https://github.com/angular-ui/ui-router/tree/gh-pages/sample)) |**
diff --git a/js/vendor/angular-ui-router/api/angular-ui-router.d.ts b/js/vendor/angular-ui-router/api/angular-ui-router.d.ts
deleted file mode 100644
index 55c5d5e0..00000000
--- a/js/vendor/angular-ui-router/api/angular-ui-router.d.ts
+++ /dev/null
@@ -1,126 +0,0 @@
-// Type definitions for Angular JS 1.1.5+ (ui.router module)
-// Project: https://github.com/angular-ui/ui-router
-// Definitions by: Michel Salib <https://github.com/michelsalib>
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-declare module ng.ui {
-
- interface IState {
- name?: string;
- template?: string;
- templateUrl?: any; // string || () => string
- templateProvider?: any; // () => string || IPromise<string>
- controller?: any;
- controllerAs?: string;
- controllerProvider?: any;
- resolve?: {};
- url?: string;
- params?: any;
- views?: {};
- abstract?: boolean;
- onEnter?: (...args: any[]) => void;
- onExit?: (...args: any[]) => void;
- data?: any;
- reloadOnSearch?: boolean;
- }
-
- interface ITypedState<T> extends IState {
- data?: T;
- }
-
- interface IStateProvider extends IServiceProvider {
- state(name: string, config: IState): IStateProvider;
- state(config: IState): IStateProvider;
- decorator(name?: string, decorator?: (state: IState, parent: Function) => any): any;
- }
-
- interface IUrlMatcher {
- concat(pattern: string): IUrlMatcher;
- exec(path: string, searchParams: {}): {};
- parameters(): string[];
- format(values: {}): string;
- }
-
- interface IUrlMatcherFactory {
- compile(pattern: string): IUrlMatcher;
- isMatcher(o: any): boolean;
- }
-
- interface IUrlRouterProvider extends IServiceProvider {
- when(whenPath: RegExp, handler: Function): IUrlRouterProvider;
- when(whenPath: RegExp, handler: any[]): IUrlRouterProvider;
- when(whenPath: RegExp, toPath: string): IUrlRouterProvider;
- when(whenPath: IUrlMatcher, hanlder: Function): IUrlRouterProvider;
- when(whenPath: IUrlMatcher, handler: any[]): IUrlRouterProvider;
- when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider;
- when(whenPath: string, handler: Function): IUrlRouterProvider;
- when(whenPath: string, handler: any[]): IUrlRouterProvider;
- when(whenPath: string, toPath: string): IUrlRouterProvider;
- otherwise(handler: Function): IUrlRouterProvider;
- otherwise(handler: any[]): IUrlRouterProvider;
- otherwise(path: string): IUrlRouterProvider;
- rule(handler: Function): IUrlRouterProvider;
- rule(handler: any[]): IUrlRouterProvider;
- }
-
- interface IStateOptions {
- location?: any;
- inherit?: boolean;
- relative?: IState;
- notify?: boolean;
- reload?: boolean;
- }
-
- interface IHrefOptions {
- lossy?: boolean;
- inherit?: boolean;
- relative?: IState;
- absolute?: boolean;
- }
-
- interface IStateService {
- go(to: string, params?: {}, options?: IStateOptions): IPromise<any>;
- transitionTo(state: string, params?: {}, updateLocation?: boolean): void;
- transitionTo(state: string, params?: {}, options?: IStateOptions): void;
- includes(state: string, params?: {}): boolean;
- is(state:string, params?: {}): boolean;
- is(state: IState, params?: {}): boolean;
- href(state: IState, params?: {}, options?: IHrefOptions): string;
- href(state: string, params?: {}, options?: IHrefOptions): string;
- get(state: string): IState;
- get(): IState[];
- current: IState;
- params: any;
- reload(): void;
- }
-
- interface IStateParamsService {
- [key: string]: any;
- }
-
- interface IStateParams {
- [key: string]: any;
- }
-
- interface IUrlRouterService {
- /*
- * Triggers an update; the same update that happens when the address bar
- * url changes, aka $locationChangeSuccess.
- *
- * This method is useful when you need to use preventDefault() on the
- * $locationChangeSuccess event, perform some custom logic (route protection,
- * auth, config, redirection, etc) and then finally proceed with the transition
- * by calling $urlRouter.sync().
- *
- */
- sync(): void;
- }
-
- interface IUiViewScrollProvider {
- /*
- * Reverts back to using the core $anchorScroll service for scrolling
- * based on the url anchor.
- */
- useAnchorScroll(): void;
- }
-}
diff --git a/js/vendor/angular-ui-router/bower.json b/js/vendor/angular-ui-router/bower.json
index f4f08fa2..fb5256ac 100644
--- a/js/vendor/angular-ui-router/bower.json
+++ b/js/vendor/angular-ui-router/bower.json
@@ -1,6 +1,7 @@
{
"name": "angular-ui-router",
- "version": "0.2.15",
+ "version": "0.2.17",
+ "license" : "MIT",
"main": "./release/angular-ui-router.js",
"dependencies": {
"angular": ">= 1.0.8"
diff --git a/js/vendor/angular-ui-router/release/angular-ui-router.js b/js/vendor/angular-ui-router/release/angular-ui-router.js
index 57c62cca..f1214062 100644
--- a/js/vendor/angular-ui-router/release/angular-ui-router.js
+++ b/js/vendor/angular-ui-router/release/angular-ui-router.js
@@ -1,6 +1,6 @@
/**
* State-based routing for AngularJS
- * @version v0.2.15
+ * @version v0.2.17
* @link http://angular-ui.github.com/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
@@ -22,7 +22,8 @@ var isDefined = angular.isDefined,
isArray = angular.isArray,
forEach = angular.forEach,
extend = angular.extend,
- copy = angular.copy;
+ copy = angular.copy,
+ toJson = angular.toJson;
function inherit(parent, extra) {
return extend(new (extend(function() {}, { prototype: parent }))(), extra);
@@ -109,7 +110,7 @@ function inheritParams(currentParams, newParams, $current, $to) {
var parents = ancestors($current, $to), parentParams, inherited = {}, inheritList = [];
for (var i in parents) {
- if (!parents[i].params) continue;
+ if (!parents[i] || !parents[i].params) continue;
parentParams = objectKeys(parents[i].params);
if (!parentParams.length) continue;
@@ -746,13 +747,13 @@ function UrlMatcher(pattern, config, parentMatcher) {
// The regular expression is somewhat complicated due to the need to allow curly braces
// inside the regular expression. The placeholder regexp breaks down as follows:
// ([:*])([\w\[\]]+) - classic placeholder ($1 / $2) (search version has - for snake-case)
- // \{([\w\[\]]+)(?:\:( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case
+ // \{([\w\[\]]+)(?:\:\s*( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case
// (?: ... | ... | ... )+ - the regexp consists of any number of atoms, an atom being either
// [^{}\\]+ - anything other than curly braces or backslash
// \\. - a backslash escape
// \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms
- var placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,
- searchPlaceholder = /([:]?)([\w\[\]-]+)|\{([\w\[\]-]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,
+ var placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,
+ searchPlaceholder = /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,
compiled = '^', last = 0, m,
segments = this.segments = [],
parentParams = parentMatcher ? parentMatcher.params : {},
@@ -762,7 +763,7 @@ function UrlMatcher(pattern, config, parentMatcher) {
function addParameter(id, type, config, location) {
paramNames.push(id);
if (parentParams[id]) return parentParams[id];
- if (!/^\w+(-+\w+)*(?:\[\])?$/.test(id)) throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'");
+ if (!/^\w+([-.]+\w+)*(?:\[\])?$/.test(id)) throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'");
if (params[id]) throw new Error("Duplicate parameter name '" + id + "' in pattern '" + pattern + "'");
params[id] = new $$UMFP.Param(id, type, config, location);
return params[id];
@@ -773,7 +774,10 @@ function UrlMatcher(pattern, config, parentMatcher) {
if (!pattern) return result;
switch(squash) {
case false: surroundPattern = ['(', ')' + (optional ? "?" : "")]; break;
- case true: surroundPattern = ['?(', ')?']; break;
+ case true:
+ result = result.replace(/\/$/, '');
+ surroundPattern = ['(?:\/(', ')|\/)?'];
+ break;
default: surroundPattern = ['(' + squash + "|", ')?']; break;
}
return result + surroundPattern[0] + pattern + surroundPattern[1];
@@ -789,7 +793,11 @@ function UrlMatcher(pattern, config, parentMatcher) {
cfg = config.params[id];
segment = pattern.substring(last, m.index);
regexp = isSearch ? m[4] : m[4] || (m[1] == '*' ? '.*' : null);
- type = $$UMFP.type(regexp || "string") || inherit($$UMFP.type("string"), { pattern: new RegExp(regexp, config.caseInsensitive ? 'i' : undefined) });
+
+ if (regexp) {
+ type = $$UMFP.type(regexp) || inherit($$UMFP.type("string"), { pattern: new RegExp(regexp, config.caseInsensitive ? 'i' : undefined) });
+ }
+
return {
id: id, regexp: regexp, segment: segment, type: type, cfg: cfg
};
@@ -919,20 +927,29 @@ UrlMatcher.prototype.exec = function (path, searchParams) {
return map(allReversed, unquoteDashes).reverse();
}
+ var param, paramVal;
for (i = 0; i < nPath; i++) {
paramName = paramNames[i];
- var param = this.params[paramName];
- var paramVal = m[i+1];
+ param = this.params[paramName];
+ paramVal = m[i+1];
// if the param value matches a pre-replace pair, replace the value before decoding.
- for (j = 0; j < param.replace; j++) {
+ for (j = 0; j < param.replace.length; j++) {
if (param.replace[j].from === paramVal) paramVal = param.replace[j].to;
}
if (paramVal && param.array === true) paramVal = decodePathArray(paramVal);
+ if (isDefined(paramVal)) paramVal = param.type.decode(paramVal);
values[paramName] = param.value(paramVal);
}
for (/**/; i < nTotal; i++) {
paramName = paramNames[i];
values[paramName] = this.params[paramName].value(searchParams[paramName]);
+ param = this.params[paramName];
+ paramVal = searchParams[paramName];
+ for (j = 0; j < param.replace.length; j++) {
+ if (param.replace[j].from === paramVal) paramVal = param.replace[j].to;
+ }
+ if (isDefined(paramVal)) paramVal = param.type.decode(paramVal);
+ values[paramName] = param.value(paramVal);
}
return values;
@@ -956,7 +973,7 @@ UrlMatcher.prototype.parameters = function (param) {
/**
* @ngdoc function
- * @name ui.router.util.type:UrlMatcher#validate
+ * @name ui.router.util.type:UrlMatcher#validates
* @methodOf ui.router.util.type:UrlMatcher
*
* @description
@@ -1009,6 +1026,8 @@ UrlMatcher.prototype.format = function (values) {
if (isPathParam) {
var nextSegment = segments[i + 1];
+ var isFinalPathParam = i + 1 === nPath;
+
if (squash === false) {
if (encoded != null) {
if (isArray(encoded)) {
@@ -1024,9 +1043,12 @@ UrlMatcher.prototype.format = function (values) {
} else if (isString(squash)) {
result += squash + nextSegment;
}
+
+ if (isFinalPathParam && param.squash === true && result.slice(-1) === '/') result = result.slice(0, -1);
} else {
if (encoded == null || (isDefaultValue && squash !== false)) continue;
if (!isArray(encoded)) encoded = [ encoded ];
+ if (encoded.length === 0) continue;
encoded = map(encoded, encodeURIComponent).join('&' + name + '=');
result += (search ? '&' : '?') + (name + '=' + encoded);
search = true;
@@ -1191,6 +1213,7 @@ Type.prototype.$asArray = function(mode, isSearch) {
// Wraps type (.is/.encode/.decode) functions to operate on each value of an array
function arrayHandler(callback, allTruthyMode) {
return function handleArray(val) {
+ if (isArray(val) && val.length === 0) return val;
val = arrayWrap(val);
var result = map(val, callback);
if (allTruthyMode === true)
@@ -1239,8 +1262,12 @@ function $UrlMatcherFactory() {
var isCaseInsensitive = false, isStrictMode = true, defaultSquashPolicy = false;
- function valToString(val) { return val != null ? val.toString().replace(/\//g, "%2F") : val; }
- function valFromString(val) { return val != null ? val.toString().replace(/%2F/g, "/") : val; }
+ // Use tildes to pre-encode slashes.
+ // If the slashes are simply URLEncoded, the browser can choose to pre-decode them,
+ // and bidirectional encoding/decoding fails.
+ // Tilde was chosen because it's not a RFC 3986 section 2.2 Reserved Character
+ function valToString(val) { return val != null ? val.toString().replace(/~/g, "~~").replace(/\//g, "~2F") : val; }
+ function valFromString(val) { return val != null ? val.toString().replace(/~2F/g, "/").replace(/~~/g, "~") : val; }
var $types = {}, enqueue = true, typeQueue = [], injector, defaultTypes = {
string: {
@@ -1583,7 +1610,12 @@ function $UrlMatcherFactory() {
if (config.type && urlType) throw new Error("Param '"+id+"' has two type configurations.");
if (urlType) return urlType;
if (!config.type) return (location === "config" ? $types.any : $types.string);
- return config.type instanceof Type ? config.type : new Type(config.type);
+
+ if (angular.isString(config.type))
+ return $types[config.type];
+ if (config.type instanceof Type)
+ return config.type;
+ return new Type(config.type);
}
// array config: param name (param[]) overrides default settings. explicit config overrides param name.
@@ -1778,7 +1810,7 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
* });
* </pre>
*
- * @param {object} rule Handler function that takes `$injector` and `$location`
+ * @param {function} rule Handler function that takes `$injector` and `$location`
* services as arguments. You can use them to return a valid path as a string.
*
* @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
@@ -1814,7 +1846,7 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
* });
* </pre>
*
- * @param {string|object} rule The url path you want to redirect to or a function
+ * @param {string|function} rule The url path you want to redirect to or a function
* rule that returns the url path. The function version is passed two params:
* `$injector` and `$location` services, and must return a url string.
*
@@ -1843,7 +1875,9 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
* @methodOf ui.router.router.$urlRouterProvider
*
* @description
- * Registers a handler for a given url matching. if handle is a string, it is
+ * Registers a handler for a given url matching.
+ *
+ * If the handler is a string, it is
* treated as a redirect, and is interpolated according to the syntax of match
* (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).
*
@@ -1872,7 +1906,7 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
* </pre>
*
* @param {string|object} what The incoming path that you want to redirect.
- * @param {string|object} handler The path you want to redirect your user to.
+ * @param {string|function} handler The path you want to redirect your user to.
*/
this.when = function (what, handler) {
var redirect, handlerIsString = isString(handler);
@@ -1983,8 +2017,8 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
*
*/
this.$get = $get;
- $get.$inject = ['$location', '$rootScope', '$injector', '$browser'];
- function $get( $location, $rootScope, $injector, $browser) {
+ $get.$inject = ['$location', '$rootScope', '$injector', '$browser', '$sniffer'];
+ function $get( $location, $rootScope, $injector, $browser, $sniffer) {
var baseHref = $browser.baseHref(), location = $location.url(), lastPushedUrl;
@@ -2024,6 +2058,12 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
return listener;
}
+ rules.sort(function(ruleA, ruleB) {
+ var aLength = ruleA.prefix ? ruleA.prefix.length : 0;
+ var bLength = ruleB.prefix ? ruleB.prefix.length : 0;
+ return bLength - aLength;
+ });
+
if (!interceptDeferred) listen();
return {
@@ -2117,6 +2157,8 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
if (angular.isObject(isHtml5)) {
isHtml5 = isHtml5.enabled;
}
+
+ isHtml5 = isHtml5 && $sniffer.history;