diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-06 18:18:06 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-06 19:04:11 -0400 |
| commit | 50c06cc74b025e98ebccc90d389d42354f2b2d63 (patch) | |
| tree | 4fad3364b5ad4b6f358e8e892ecbfd4aa53c0215 /app/node_modules/okutil/index.js | |
| parent | c52afebd8ac9c061d4ac37d6ebabef922be8af9e (diff) | |
Add trailing slash utility functions
Diffstat (limited to 'app/node_modules/okutil/index.js')
| -rw-r--r-- | app/node_modules/okutil/index.js | 17 |
1 files changed, 17 insertions, 0 deletions
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; } }; |
