Unverified Commit d8731882 authored by Aral's ThinkPad's avatar Aral's ThinkPad
Browse files

Handle trailing slashes in route names properly on Windows

Bump version to 1.2.1
parent 03ebdfe8
......@@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Nothing yet.
## [1.2.1] - 2019-09-29
### Fixed
- Trailing slashes in routes are now handled the same way under Windows as on other platforms.
## [1.2.0] - 2019-09-28
### Added
......
......@@ -35,6 +35,10 @@ function routes (directory, directoryRoot = null) {
routeUrlPath = routeUrlPath.replace(/\/$/, '')
// On Windows, the file path slashes are backwards so we have to reverse them.
if (process.platform === 'win32') {
// Since the code replacing the forward slash at the end will not have caught a backslash at the end
// on Windows, do that now.
routeUrlPath = routeUrlPath.replace(/\\$/, '')
// Replace all backslashes with forwardslashes.
routeUrlPath = routeUrlPath.replace(/\\/g, '/')
}
if (!routeUrlPath.startsWith('/')) routeUrlPath = `/${routeUrlPath}`
......
{
"name": "@ind.ie/web-routes-from-files",
"version": "1.2.0",
"version": "1.2.1",
"description": "Recursively traverses a given directory structure and uses convention to create a list of web route objects that map url paths to JavaScript callback files.",
"main": "index.js",
"directories": {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment