Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/urlMatcherFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ UrlMatcher.prototype.concat = function (pattern, config) {
// Because order of search parameters is irrelevant, we can add our own search
// parameters to the end of the new pattern. Parse the new pattern by itself
// and then join the bits together, but it's much easier to do this on a string level.
return new UrlMatcher(this.sourcePath + pattern + this.sourceSearch, config);
return new $$UrlMatcherFactoryProvider.compile(this.sourcePath + pattern + this.sourceSearch, config);
};

UrlMatcher.prototype.toString = function () {
Expand Down Expand Up @@ -435,6 +435,7 @@ Type.prototype.$subPattern = function() {

Type.prototype.pattern = /.*/;

var $$UrlMatcherFactoryProvider;
/**
* @ngdoc object
* @name ui.router.util.$urlMatcherFactory
Expand All @@ -444,6 +445,7 @@ Type.prototype.pattern = /.*/;
* is also available to providers under the name `$urlMatcherFactoryProvider`.
*/
function $UrlMatcherFactory() {
$$UrlMatcherFactoryProvider = this;

var isCaseInsensitive = false, isStrictMode = true;

Expand Down Expand Up @@ -546,7 +548,7 @@ function $UrlMatcherFactory() {
*
* @description
* Creates a {@link ui.router.util.type:UrlMatcher `UrlMatcher`} for the specified pattern.
*
*
* @param {string} pattern The URL pattern.
* @param {Object} config The config object hash.
* @returns {UrlMatcher} The UrlMatcher.
Expand Down
39 changes: 26 additions & 13 deletions test/urlMatcherFactorySpec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
describe("UrlMatcher", function () {
var provider;
beforeEach(function() {
angular.module('ui.router.router.test', function() {}).config(function ($urlMatcherFactoryProvider) {
provider = $urlMatcherFactoryProvider;
});

describe("provider", function () {

var provider;

beforeEach(function() {
angular.module('ui.router.router.test', function() {}).config(function ($urlMatcherFactoryProvider) {
provider = $urlMatcherFactoryProvider;
});

module('ui.router.router', 'ui.router.router.test');
module('ui.router.router', 'ui.router.router.test');

inject(function($injector) {
$injector.invoke(provider.$get);
});
inject(function($injector) {
$injector.invoke(provider.$get);
});
});

describe("provider", function () {
it("should factory matchers with correct configuration", function () {
provider.caseInsensitive(false);
expect(provider.compile('/hello').exec('/HELLO')).toBeNull();
Expand Down Expand Up @@ -165,6 +162,22 @@ describe("UrlMatcher", function () {
var matcher = base.concat('/{repeat:[0-9]+}?to');
expect(matcher).toNotBe(base);
});

it("should respect $urlMatcherFactoryProvider.strictMode", function() {
var m = new UrlMatcher('/');
provider.strictMode(false);
m = m.concat("foo");
expect(m.exec("/foo")).toEqual({});
expect(m.exec("/foo/")).toEqual({})
});

it("should respect $urlMatcherFactoryProvider.caseInsensitive", function() {
var m = new UrlMatcher('/');
provider.caseInsensitive(true);
m = m.concat("foo");
expect(m.exec("/foo")).toEqual({});
expect(m.exec("/FOO")).toEqual({});
});
});
});

Expand Down