redirect_on_back 0.0.4 → 0.0.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGE2OWE2OWUzMzA1NjNiODYwODJjM2E1ZjYyMDUxODg2OTc1YmVlMw==
4
+ MWU0ZDJkZTk4MmYzY2Q5ZTczMmZiNGQwNTYzNDRjYjY4ZmQ3YmE0Zg==
5
5
  data.tar.gz: !binary |-
6
- MmU0ZDQ1ZWQ4M2RiMGJlMmMwOTFmMDBiODVmODFkOWZiNDExN2U1NA==
6
+ ZjJjZWRiYmZjMTYzZDA1MjY3MWQzNGMyMjI0NWRmZGQ3MGE2Mjk2Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OGFhMDEyNjQ0MzYzNjk1Y2VhMjZhZTYwMDcyN2M3MGZkYmI5NmUzMmUzNTZl
10
- OTc4ZTNkNjMyZmQwZGM4NDc2ZDZkMzRlOGZlNDUzZGVlZWMyZmFjYmJkMDJj
11
- ZTc1YjFjM2E0MTVjZWEzNzQ1YTE3ZDFlYjRkYjJkNjg3MjgwNzg=
9
+ MzE0NmIyOWY3MjJjNzJmYTFjYzkwYTU4NzNlYmZlNjQ2NzE3NWFlM2NkNGU5
10
+ OTA0ZjFmZTMyNGEwZDY4ZTk3MzZiZTI1MDU0MDdhODczN2M0MzJjZGNkNDAx
11
+ NGViYTlhNzMyYzEwNmE0YjcwZTMzMmFiYjk3NDg4ODgxMzQ4ZmE=
12
12
  data.tar.gz: !binary |-
13
- OWNlNDVjMGNkYzZkN2NkYmJiNjg1ZDI3YjdhZjhkMGYyMjhlZWIyMTJhNmI0
14
- NjM3ZTAxYTBjZDY2MWFiNmE0ZTQwODE5N2E0MzViM2E4ODRiZWIxYzcyZTY4
15
- ZGQ3OWM0MjEwZWFiNTJhNzhmMjE3NzNkMjgzMjk4ZDBkZTZkZTc=
13
+ ZTdhYTZlOGY1YzNjZjRlYzU5NjYyNTBiOWQ3MzY5NDIxZWM1ZGU0ZWYzMTI1
14
+ MWRkOGZlY2JhZGMxN2ZlYTg5NTc1NzliMTFiMTJkMmIxYTRlMzIwMzdhZmU4
15
+ Y2I4MThhMTkyMmUzNTAwMWE1YWVmMjg0NzNkYzVjNmVhNDNhYjE=
data/README.md CHANGED
@@ -42,6 +42,16 @@ In your controller actions:
42
42
  end
43
43
  ```
44
44
 
45
+ ## How to Disable
46
+
47
+ `redirect_on_back` uses a hidden form field, which it automatically adds to forms.
48
+ However, it doesn't add the field to forms that point to different domains.
49
+ If you need to disable it in another forms, simply add `disable_redirect_on_back: true` to the `data` hash of that form:
50
+
51
+ ```erb
52
+ form_tag :user, data: {disable_redirect_on_back: true}
53
+ ```
54
+
45
55
  ## Contributing
46
56
 
47
57
  1. Fork it
@@ -8,11 +8,20 @@ module RedirectOnBack
8
8
 
9
9
  def extra_tags_for_form(html_options)
10
10
  orig_tags = orig_extra_tags_for_form(html_options)
11
- unless html_options.delete(:disable_redirect_on_back)
11
+ if !disable_redirect_on_back(html_options) && is_internal_action?(html_options[:action] || '/')
12
12
  orig_tags << "<input name='_usec' type='hidden' value='#{Time.now.usec}' />".html_safe
13
13
  end
14
14
  orig_tags
15
15
  end
16
+
17
+ def disable_redirect_on_back(html_options)
18
+ html_options.try(:[], :data).try(:delete, :disable_redirect_on_back)
19
+ end
20
+
21
+ def is_internal_action?(action)
22
+ (action =~ /^\//) != nil # form action starts with '/'
23
+ end
24
+
16
25
  end
17
26
  end
18
27
  end
@@ -1,3 +1,3 @@
1
1
  module RedirectOnBack
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirect_on_back
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - yossi-shasho