safe_redirect 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43ed422140bec3e839934d1ee42c78a5880d3330
4
- data.tar.gz: 281fee30b7c0561af01dab24e6648acace4cac40
3
+ metadata.gz: 5a6d01c7330bafc677a98f499e04b7db0a6c27cf
4
+ data.tar.gz: 1672f119857023640eda0223d20e72a214de0129
5
5
  SHA512:
6
- metadata.gz: 359447032c5989940323a03c422b21d72eac5d4ca48b49c2d70ac22f90a5b2c5463417c12c21f1890dd0895f3178cfb3e6ffe04b5a3d4bb42ea931df05e13673
7
- data.tar.gz: 0c4d28bd7613577ae102cf20e77852bf6888471416b4ef635bb05084a17d81ddfd15f7dc0b9093f5fe57c813c981bc60e62def8947fd25927ea1363fd9a83430
6
+ metadata.gz: 8b9cb5dc6823258bbe67023e1788fe357328e51bd9511345edea8048505ea269641dca477cc9df62fadd038d03065e5676d2d2b1e2365689451b2eaa718b761f
7
+ data.tar.gz: df89615fd2dbef7f302024a2ae396e70a6329378e6d38e8242c62d18cc9aa2824f768c740fcaec5f7c79f31fcc4e02b99b347f8c72d575a89895f6e06321fb46
@@ -10,7 +10,7 @@ module SafeRedirect
10
10
  case
11
11
  when path.kind_of?(String)
12
12
  clean_path(path)
13
- when path.kind_of?(Symbol)
13
+ when path.kind_of?(Symbol) || path.kind_of?(Hash)
14
14
  path
15
15
  else
16
16
  SafeRedirect.configuration.default_path
@@ -18,7 +18,8 @@ module SafeRedirect
18
18
  end
19
19
 
20
20
  def redirect_to(path, options={})
21
- super safe_path(path), options
21
+ target = options[:safe] ? path : safe_path(path)
22
+ super safe_path(target), options
22
23
  rescue NoMethodError
23
24
  end
24
25
 
@@ -1,3 +1,3 @@
1
1
  module SafeRedirect
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -50,6 +50,10 @@ module SafeRedirect
50
50
  expect(Controller.safe_path(:back)).to eq(:back)
51
51
  end
52
52
 
53
+ it "considers {controller: 'home', action: 'index'} a safe path" do
54
+ expect(Controller.safe_path({controller: 'home', action: 'index'})).to eq({controller: 'home', action: 'index'})
55
+ end
56
+
53
57
  it "considers https://www.bukalapak.com@google.com an unsafe path" do
54
58
  expect(Controller.safe_path('https://www.bukalapak.com@google.com')).to eq('/')
55
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_redirect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin Tunggawan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec