Skip to content

Commit

Permalink
Routes where hosts: true and disableIdParam: true now being const…
Browse files Browse the repository at this point in the history
…ructed correctly as `/:host/FeatureServer/:layer/:method` (#44)
  • Loading branch information
rgwozdz authored Aug 6, 2018
1 parent 9df1aed commit 3aa793b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

# Unreleased
### Fixed
* Routes where `hosts: true` and `disableIdParam: true` now being constructed correctly as `/:host/FeatureServer/:layer/:method`

## [3.9.0] - 2018-07-20
### Added
* Prefentially use a `createKey` function found on the Model's prototype
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function composeRouteString (routePath, namespace, opts) {
if (options.absolutePath) return path.posix.join('/', routePath)

// Build parameterized route fragment based on provider options
if (options.hosts) paramFragment = path.posix.join(':host', ':id')
if (options.hosts && !options.disableIdParam) paramFragment = path.posix.join(':host', ':id')
else if (options.hosts && options.disableIdParam) paramFragment = path.posix.join(':host')
else if (!options.disableIdParam) paramFragment = path.posix.join(':id')

// Replace placehold substrings if present, fallback to namespace/:host/:id
Expand Down
7 changes: 4 additions & 3 deletions test/helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ describe('Tests for helper functions', function () {
let fullRoute = helpers.composeRouteString('FeatureServer/:layer/:method', 'test', {hosts: true})
fullRoute.should.equal('/test/:host/:id/FeatureServer/:layer/:method')
})
it('create route with :host parameter', function () {
let fullRoute = helpers.composeRouteString('FeatureServer/:layer/:method', 'test', {hosts: true})
fullRoute.should.equal('/test/:host/:id/FeatureServer/:layer/:method')
it('create route with :host parameter and without :id parameter', function () {
let fullRoute = helpers.composeRouteString('FeatureServer/:layer/:method', 'test', {hosts: true, disableIdParam: true})
fullRoute.should.equal('/test/:host/FeatureServer/:layer/:method')
})

it('create route without :host parameter', function () {
let fullRoute = helpers.composeRouteString('FeatureServer/:layer/:method', 'test')
fullRoute.should.equal('/test/:id/FeatureServer/:layer/:method')
Expand Down

0 comments on commit 3aa793b

Please sign in to comment.