From 50c06cc74b025e98ebccc90d389d42354f2b2d63 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Mon, 6 Apr 2015 18:18:06 -0400 Subject: Add trailing slash utility functions --- app/node_modules/okutil/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'app/node_modules/okutil/index.js') diff --git a/app/node_modules/okutil/index.js b/app/node_modules/okutil/index.js index bef085c..738c6a4 100644 --- a/app/node_modules/okutil/index.js +++ b/app/node_modules/okutil/index.js @@ -1,3 +1,4 @@ +var path = require('path'); var isarray = require('lodash.isarray'); var pluralize = require('pluralize'); var Q = require('q'); @@ -35,6 +36,22 @@ module.exports = { resolve(normalized); }, reject); }); + }, + + /** + * Return a copy of the route with a trailing slash + */ + withTrailingSlash: function withTrailingSlash(route) { + route = route || ''; + return path.normalize(route + '/'); + }, + + /** + * Return a copy of the route without a trailing slash + */ + withoutTrailingSlash: function withoutTrailingSlash(route) { + route = route || ''; + return route.charAt(route.length - 1) === '/' ? route.slice(0, -1) : route; } }; -- cgit v1.2.3-70-g09d2