Skip to content

Commit 53e4240

Browse files
committed
Merge branch 'master' of https://github.com/bwillis/versioncake
2 parents 22ddf30 + b92877c commit 53e4240

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Unreleased Changes
22

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

55
Bug Fixes:
66

@@ -14,6 +14,20 @@ Deprecations:
1414

1515
* None
1616

17+
## 4.0.0 (March 10, 2020)
18+
19+
Bug Fixes:
20+
21+
* Path versions could parse incorrect version in some circumstances (#83) thanks [Luke Abel](https://github.com/llhhaa)
22+
23+
Enhancements:
24+
25+
* Rails 6 support (#81) thanks [Thomas "Teflon Ted" Davis](https://github.com/trak3r)
26+
27+
Deprecations:
28+
29+
* Remove Rails v3/v4 and Ruby <v2.3 support
30+
1731
## 3.4.0 (March 4, 2018)
1832

1933
Bug Fixes:

lib/versioncake/strategies/path_parameter_strategy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class PathParameterStrategy < ExtractionStrategy
44
def execute(request)
55
version = nil
66
request.path.split('/').find do |part|
7-
next unless match = part.match(%r{v(?<version>\d+)})
7+
next unless match = part.match(%r{\Av(?<version>\d+)\z})
88
version = match[:version]
99
break
1010
end

spec/unit/strategies/path_parameter_strategy_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@
1010
it { is_expected.to eq 11 }
1111
end
1212

13+
context "a request with a substring matching /v\d+/ returns nil" do
14+
context "as a postpended string" do
15+
let(:request) { instance_double('Request', path: 'parameter/aav11/parameter') }
16+
17+
it { is_expected.to be_nil }
18+
end
19+
20+
context "as a prepended string" do
21+
let(:request) { instance_double('Request', path: 'parameter/v11aa/parameter') }
22+
23+
it { is_expected.to be_nil }
24+
end
25+
26+
context "as an interstital string" do
27+
let(:request) { instance_double('Request', path: 'parameter/aav11aa/parameter') }
28+
29+
it { is_expected.to be_nil }
30+
end
31+
end
32+
1333
context "a request without an api_version path parameter returns nil" do
1434
let(:request) { instance_double('Request', path: 'parameter/parameter') }
1535

0 commit comments

Comments
 (0)