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
|
||||
route: '/auth'
|
||||
customRegexp: /^\/?auth($|\/)/
|
||||
connectOutlets: (router) ->
|
||||
router.get('applicationView').connectLayout 'simple'
|
||||
$('body').attr('id', 'auth')
|
||||
|
@ -88,6 +89,7 @@ Travis.Router = Ember.Router.extend
|
|||
|
||||
stats: Ember.Route.extend
|
||||
route: '/stats'
|
||||
customRegexp: /^\/?stats($|\/)/
|
||||
connectOutlets: (router) ->
|
||||
router.get('applicationView').connectLayout 'simple'
|
||||
$('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({
|
||||
route: route,
|
||||
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,
|
||||
|
||||
init: function() {
|
||||
var route = this.route,
|
||||
dynamicSegmentPattern = this.dynamicSegmentPattern || "([^/]+)",
|
||||
terminators = this.dynamicSegmentTerminators || [],
|
||||
identifiers = [],
|
||||
count = 1,
|
||||
escaped,
|
||||
segmentRegexp;
|
||||
var route = this.route;
|
||||
|
||||
// Strip off leading slash if present
|
||||
if (route.charAt(0) === '/') {
|
||||
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;
|
||||
this.regex = new RegExp("^/?" + regex);
|
||||
escaped = escapeForRegex(route);
|
||||
|
||||
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) {
|
||||
console.log(path, this.regex);
|
||||
var match = path.match(this.regex);
|
||||
|
||||
if (match) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user