From 8fb481cdd07b7f5fc6f8c033ec6f33066ac24736 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 16 Nov 2012 15:16:09 +0100 Subject: [PATCH 1/3] Slugs are case insensitive now (closes #51) --- assets/scripts/app/routes.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index 43e1394e..07acdcf4 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -195,7 +195,7 @@ Travis.Router = Ember.Router.extend router.get('repoController').set 'repo', repo deserialize: (router, params) -> - slug = "#{params.owner}/#{params.name}" + slug = "#{params.owner}/#{params.name}".toLowerCase() repos = Travis.Repo.bySlug(slug) deferred = $.Deferred() From cbd25b8821d3d3678e38d359b5063f03c37cf6f3 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 16 Nov 2012 15:42:50 +0100 Subject: [PATCH 2/3] Revert "Slugs are case insensitive now (closes #51)" This reverts commit 8fb481cdd07b7f5fc6f8c033ec6f33066ac24736. --- assets/scripts/app/routes.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index 07acdcf4..43e1394e 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -195,7 +195,7 @@ Travis.Router = Ember.Router.extend router.get('repoController').set 'repo', repo deserialize: (router, params) -> - slug = "#{params.owner}/#{params.name}".toLowerCase() + slug = "#{params.owner}/#{params.name}" repos = Travis.Repo.bySlug(slug) deferred = $.Deferred() From 3084dacaef5d5e1a4b632b0b1e566b6aed22244a Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 16 Nov 2012 17:33:06 +0100 Subject: [PATCH 3/3] 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. --- assets/scripts/app/routes.coffee | 2 ++ assets/scripts/vendor/ember.js | 45 +++++++++++++++++++------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee index 43e1394e..7172aa63 100644 --- a/assets/scripts/app/routes.coffee +++ b/assets/scripts/app/routes.coffee @@ -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') diff --git a/assets/scripts/vendor/ember.js b/assets/scripts/vendor/ember.js index 24ff6d4e..fe37a88b 100644 --- a/assets/scripts/vendor/ember.js +++ b/assets/scripts/vendor/ember.js @@ -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) {