Skip to content

Commit

Permalink
Fix incorrect route prefixing when prefix was null or empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
dopry authored and petebacondarwin committed Apr 30, 2013
1 parent fbae558 commit 65d7648
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions client/src/common/services/crudRouteProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@
// We use it to create routes for CRUD operations. We give it some basic information about
// the resource and the urls then it it returns our own special routeProvider.
this.routesFor = function(resourceName, urlPrefix, routePrefix) {
var baseUrl = urlPrefix + '/' + resourceName.toLowerCase();
var baseUrl = resourceName.toLowerCase();
var baseRoute = '/' + resourceName.toLowerCase();
routePrefix = routePrefix || urlPrefix;
var baseRoute = '/' + routePrefix + '/' + resourceName.toLowerCase();

// Prepend the urlPrefix if available.
if ( isString(urlPrefix) && urlPrefix !== '' ) {
baseUrl = urlPrefix + '/' + baseUrl;
}

// Prepend the routePrefix if it was provided;
if (routePrefix !== null && routePrefix !== undefined && routePrefix !== '') {
baseRoute = '/' + routePrefix + baseRoute;
}

// Create the templateUrl for a route to our resource that does the specified operation.
var templateUrl = function(operation) {
Expand Down

0 comments on commit 65d7648

Please sign in to comment.