From 21167ce88ea4ad594d213d3a49115f0ebbaed745 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Mon, 6 Apr 2015 19:08:07 -0400 Subject: Fix god forsaken trailing slashed issue --- app/index.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'app/index.js') diff --git a/app/index.js b/app/index.js index a639477..b8a3333 100644 --- a/app/index.js +++ b/app/index.js @@ -1,5 +1,8 @@ var path = require('path'); var format = require('util').format; +var withTrailingSlash = require('okutil').withTrailingSlash; +var withoutTrailingSlash = require('okutil').withoutTrailingSlash; +var assign = require('object-assign'); var express = require('express'); var OKQuery = require('okquery'); var OKView = require('okview'); @@ -104,8 +107,9 @@ OKCMS.prototype._createViews = function(viewConfig, db, } var queryConfig = config.data || []; var queries = createQueries(queryConfig, resourceCache); - // Instantiate! - cache[route] = OKView({ + // Don't forget to add that trailing slash if the user forgot + cache[withTrailingSlash(route)] = OKView({ + mount: 'get', // User defined views are read only route: route, template: template, queries: queries, @@ -148,20 +152,6 @@ OKCMS.prototype._createQueries = function(queryConfig, resourceCache) { }); }; -OKCMS.prototype._initViews = function(server, views) { - Object.keys(views) - // Make sure more specific routes are processed first - // TODO This is not semantically correct (bro) - // Will prob manifest bugs - .sort(function(a, b) { - return a.length < b.length; - }) - // Add the views - .forEach(function(route) { - server.addView(route, views[route]); - }); -}; - module.exports = { createApp: function(options) { -- cgit v1.2.3-70-g09d2