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 +4 -4
- data/README.md +20 -5
- data/lib/awesome_back_url.rb +1 -0
- data/lib/awesome_back_url/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7796cfe70ea2f1b38f736ca8d6b86fff196580fb8b8840a35a9398e12d6d8ee0
|
4
|
+
data.tar.gz: 83b8f7c65560eaca11e16258c2d4e9e8a927fae6bdf21d5f85b7d0650ee39bc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
data/lib/awesome_back_url.rb
CHANGED
@@ -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)
|
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.
|
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-
|
11
|
+
date: 2019-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|