Update Ember.js from drogus/ember.js and fix routes
Default regexp used in ember does not work well for us. With repos starting with 'stats', ember will match such url for /stats/ page, even though the rest of the url is different, I added ability to overwrite default regexp.
This commit is contained in:
parent
cbd25b8821
commit
3084dacaef
|
@ -77,6 +77,7 @@ Travis.Router = Ember.Router.extend
|
||||||
|
|
||||||
auth: Ember.Route.extend
|
auth: Ember.Route.extend
|
||||||
route: '/auth'
|
route: '/auth'
|
||||||
|
customRegexp: /^\/?auth($|\/)/
|
||||||
connectOutlets: (router) ->
|
connectOutlets: (router) ->
|
||||||
router.get('applicationView').connectLayout 'simple'
|
router.get('applicationView').connectLayout 'simple'
|
||||||
$('body').attr('id', 'auth')
|
$('body').attr('id', 'auth')
|
||||||
|
@ -88,6 +89,7 @@ Travis.Router = Ember.Router.extend
|
||||||
|
|
||||||
stats: Ember.Route.extend
|
stats: Ember.Route.extend
|
||||||
route: '/stats'
|
route: '/stats'
|
||||||
|
customRegexp: /^\/?stats($|\/)/
|
||||||
connectOutlets: (router) ->
|
connectOutlets: (router) ->
|
||||||
router.get('applicationView').connectLayout 'simple'
|
router.get('applicationView').connectLayout 'simple'
|
||||||
$('body').attr('id', 'stats')
|
$('body').attr('id', 'stats')
|
||||||
|
|
45
assets/scripts/vendor/ember.js
vendored
45
assets/scripts/vendor/ember.js
vendored
|
@ -17773,7 +17773,8 @@ Ember.Routable = Ember.Mixin.create({
|
||||||
return Ember._RouteMatcher.create({
|
return Ember._RouteMatcher.create({
|
||||||
route: route,
|
route: route,
|
||||||
dynamicSegmentPattern: get(this, 'dynamicSegmentPattern'),
|
dynamicSegmentPattern: get(this, 'dynamicSegmentPattern'),
|
||||||
dynamicSegmentTerminators: get(this, 'dynamicSegmentTerminators')
|
dynamicSegmentTerminators: get(this, 'dynamicSegmentTerminators'),
|
||||||
|
customRegexp: get(this, 'customRegexp')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
@ -18161,34 +18162,42 @@ Ember._RouteMatcher = Ember.Object.extend({
|
||||||
state: null,
|
state: null,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
var route = this.route,
|
var route = this.route;
|
||||||
dynamicSegmentPattern = this.dynamicSegmentPattern || "([^/]+)",
|
|
||||||
terminators = this.dynamicSegmentTerminators || [],
|
|
||||||
identifiers = [],
|
|
||||||
count = 1,
|
|
||||||
escaped,
|
|
||||||
segmentRegexp;
|
|
||||||
|
|
||||||
// Strip off leading slash if present
|
// Strip off leading slash if present
|
||||||
if (route.charAt(0) === '/') {
|
if (route.charAt(0) === '/') {
|
||||||
route = this.route = route.substr(1);
|
route = this.route = route.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
escaped = escapeForRegex(route);
|
if(this.customRegexp) {
|
||||||
|
this.identifiers = [];
|
||||||
|
this.regex = this.customRegexp;
|
||||||
|
} else {
|
||||||
|
var dynamicSegmentPattern = this.dynamicSegmentPattern || "([^/]+)",
|
||||||
|
terminators = this.dynamicSegmentTerminators || [],
|
||||||
|
identifiers = [],
|
||||||
|
count = 1,
|
||||||
|
escaped,
|
||||||
|
segmentRegexp;
|
||||||
|
|
||||||
terminators.push('$|/');
|
|
||||||
str = ':([a-z_]+)(?=' + terminators.join('|') + ')'
|
|
||||||
segmentRegexp = new RegExp(str, 'gi');
|
|
||||||
var regex = escaped.replace(segmentRegexp, function(match, id) {
|
|
||||||
identifiers[count++] = id;
|
|
||||||
return dynamicSegmentPattern;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.identifiers = identifiers;
|
escaped = escapeForRegex(route);
|
||||||
this.regex = new RegExp("^/?" + regex);
|
|
||||||
|
terminators.push('$|/');
|
||||||
|
str = ':([a-z_]+)(?=' + terminators.join('|') + ')'
|
||||||
|
segmentRegexp = new RegExp(str, 'gi');
|
||||||
|
var regex = escaped.replace(segmentRegexp, function(match, id) {
|
||||||
|
identifiers[count++] = id;
|
||||||
|
return dynamicSegmentPattern;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.identifiers = identifiers;
|
||||||
|
this.regex = new RegExp("^/?" + regex);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
match: function(path) {
|
match: function(path) {
|
||||||
|
console.log(path, this.regex);
|
||||||
var match = path.match(this.regex);
|
var match = path.match(this.regex);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user