awesome_back_url 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b258250b23be794910a6c16e2f211213fd31667d89165a70aae46349dca34ad0
4
- data.tar.gz: eee8a71a22e5f61f712789accc800cb27f41de3e7691f10bedd9a230f3754713
3
+ metadata.gz: 7796cfe70ea2f1b38f736ca8d6b86fff196580fb8b8840a35a9398e12d6d8ee0
4
+ data.tar.gz: 83b8f7c65560eaca11e16258c2d4e9e8a927fae6bdf21d5f85b7d0650ee39bc6
5
5
  SHA512:
6
- metadata.gz: a2a83f18b99e63f05f255399cc459c818ac6484d8f8cf6749b083bdb69354aa5fca0917f9c0e2ef516c8310cca45d69000d2008f85e1f0c12aaa18cbc6b8a4d2
7
- data.tar.gz: 01c66012327c54bc28b4abdb6de639244df3d30d010b1d42f7c88d2a424afc52afcd433688be78872798bb6cb465a3991278420b1723ed09916ffd78e635161a
6
+ metadata.gz: aeefc096e97a299f9743339f79d8a0235970808167df7b7c6c486338c5b974af3c32d22b317d90036b72e1351c450b8643cd35b155e8131238183072c7c5982c
7
+ data.tar.gz: 57eab5cedb12e8840b99005ec09a0aa262fbbbe03dd4b7347866511708465726a82bab6c8a6695bc9320a51169d5f2c911dd1215e3755ad47c0e43fc028d18c3
data/README.md CHANGED
@@ -4,12 +4,27 @@ Redirect to proper back URL for your Rails applications. In case if you want to
4
4
 
5
5
  ## Usage
6
6
 
7
+ Options:
8
+
9
+ ```ruby
10
+ awesome_back_path(path = request.referrer, only: nil, except: nil, fallback: :back)
11
+ ```
12
+
13
+ * "path" - destination to redirect user
14
+ * "only" - regexp of allowed paths
15
+ * "except" - regexp of disallowed paths
16
+ * "fallback" - if path is incorrect (not allowed or not in allowed) redirect to this url.
17
+
18
+ Samples:
19
+
20
+
7
21
  ```ruby
8
- link_to 'Back', awesome_back_path(except: /\/new|\/edit/, fallback: users_path) # returns '/users'
9
- link_to 'Back', awesome_back_path('/path', except: /\/new|\/edit/, fallback: '/users') # returns '/path'
10
- link_to 'Back', awesome_back_path('/path/new', except: /\/new|\/edit/, fallback: '/users') # returns '/users'
11
- link_to 'Back', awesome_back_path('/path/edit', except: /\/new|\/edit/, fallback: '/users') # returns '/users'
12
- link_to 'Back', awesome_back_path('/path', only: /\/new|\/edit/, fallback: '/users') # returns '/users'
22
+ link_to 'Back', awesome_back_path(except: /\/new|\/edit/, fallback: users_path) # returns '/users'
23
+ link_to 'Back', awesome_back_path('/path', except: /\/new/, fallback: '/users') # returns '/path'
24
+ link_to 'Back', awesome_back_path('/path/new', except: /\/new|\/edit/, fallback: '/users') # returns '/users'
25
+ link_to 'Back', awesome_back_path('/path/edit', except: /\/new|\/edit/, fallback: '/users') # returns '/users'
26
+ link_to 'Back', awesome_back_path('/path', only: /\/new|\/edit/, fallback: '/users') # returns '/users'
27
+ link_to 'Back', awesome_back_url('/path', fallback: '/users') # returns '/path'
13
28
  ```
14
29
 
15
30
  ## Installation
@@ -10,6 +10,7 @@ module AwesomeBackUrl
10
10
 
11
11
  def awesome_back_path(path = request.referrer, only: nil, except: nil, fallback: :back)
12
12
  return fallback if path.blank?
13
+ return fallback if !request.path.blank? && path =~ /#{request.path}$/
13
14
 
14
15
  if only.present?
15
16
  raise "Only regexp is allowed for \"only\" parameter" unless only.is_a?(Regexp)
@@ -1,3 +1,3 @@
1
1
  module AwesomeBackUrl
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_back_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2019-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails