Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/bwillis/versioncake
Browse files Browse the repository at this point in the history
  • Loading branch information
bwillis committed Mar 11, 2020
2 parents 22ddf30 + b92877c commit 53e4240
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Unreleased Changes

[Full Changelog](https://github.com/bwillis/versioncake/compare/v3.4...master)
[Full Changelog](https://github.com/bwillis/versioncake/compare/v4.0...master)

Bug Fixes:

Expand All @@ -14,6 +14,20 @@ Deprecations:

* None

## 4.0.0 (March 10, 2020)

Bug Fixes:

* Path versions could parse incorrect version in some circumstances (#83) thanks [Luke Abel](https://github.com/llhhaa)

Enhancements:

* Rails 6 support (#81) thanks [Thomas "Teflon Ted" Davis](https://github.com/trak3r)

Deprecations:

* Remove Rails v3/v4 and Ruby <v2.3 support

## 3.4.0 (March 4, 2018)

Bug Fixes:
Expand Down
2 changes: 1 addition & 1 deletion lib/versioncake/strategies/path_parameter_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class PathParameterStrategy < ExtractionStrategy
def execute(request)
version = nil
request.path.split('/').find do |part|
next unless match = part.match(%r{v(?<version>\d+)})
next unless match = part.match(%r{\Av(?<version>\d+)\z})
version = match[:version]
break
end
Expand Down
20 changes: 20 additions & 0 deletions spec/unit/strategies/path_parameter_strategy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@
it { is_expected.to eq 11 }
end

context "a request with a substring matching /v\d+/ returns nil" do
context "as a postpended string" do
let(:request) { instance_double('Request', path: 'parameter/aav11/parameter') }

it { is_expected.to be_nil }
end

context "as a prepended string" do
let(:request) { instance_double('Request', path: 'parameter/v11aa/parameter') }

it { is_expected.to be_nil }
end

context "as an interstital string" do
let(:request) { instance_double('Request', path: 'parameter/aav11aa/parameter') }

it { is_expected.to be_nil }
end
end

context "a request without an api_version path parameter returns nil" do
let(:request) { instance_double('Request', path: 'parameter/parameter') }

Expand Down

0 comments on commit 53e4240

Please sign in to comment.