You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements optional parameters and default parameter values. [BC-BREAK]: the `params` option in state configurations must now be an object keyed by parameter name.
Copy file name to clipboardExpand all lines: src/urlMatcherFactory.js
+57-33
Original file line number
Diff line number
Diff line change
@@ -38,8 +38,11 @@
38
38
* path into the parameter 'path'.
39
39
* * `'/files/*path'` - ditto.
40
40
*
41
-
* @param {string} pattern the pattern to compile into a matcher.
42
-
* @param {bool} caseInsensitiveMatch true if url matching should be case insensitive, otherwise false, the default value (for backward compatibility) is false.
41
+
* @param {string} pattern The pattern to compile into a matcher.
42
+
* @param {config} config A configuration object hash:
43
+
*
44
+
* * `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`.
45
+
* * `strict` - `false` if matching against a URL with a trailing slash should be treated as equivalent to a URL without a trailing slash, the default value is `true`.
43
46
*
44
47
* @property {string} prefix A static prefix of this pattern. The matcher guarantees that any
45
48
* URL matching this matcher (i.e. any string for which {@link ui.router.util.type:UrlMatcher#methods_exec exec()} returns
@@ -54,9 +57,10 @@
54
57
* @property {string} regex The constructed regex that will be used to match against the url when
55
58
* it is time to determine which url will match.
56
59
*
57
-
* @returns {Object} New UrlMatcher object
60
+
* @returns {Object} New `UrlMatcher` object
58
61
*/
59
-
functionUrlMatcher(pattern,caseInsensitiveMatch){
62
+
functionUrlMatcher(pattern,config){
63
+
config=angular.isObject(config) ? config : {};
60
64
61
65
// Find all placeholders and create a compiled pattern, using either classic or curly syntax:
62
66
// '*' name
@@ -76,32 +80,41 @@ function UrlMatcher(pattern, caseInsensitiveMatch) {
76
80
segments=this.segments=[],
77
81
params=this.params={};
78
82
79
-
functionaddParameter(id,type){
83
+
functionaddParameter(id,type,config){
80
84
if(!/^\w+(-+\w+)*$/.test(id))thrownewError("Invalid parameter name '"+id+"' in pattern '"+pattern+"'");
81
85
if(params[id])thrownewError("Duplicate parameter name '"+id+"' in pattern '"+pattern+"'");
0 commit comments