safe_target_blank 1.0.1 → 1.0.2
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 +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +4 -1
- data/Appraisals +7 -0
- data/README.md +8 -5
- data/Rakefile +6 -1
- data/bin/setup +2 -1
- data/gemfiles/rails_4.gemfile +8 -0
- data/gemfiles/rails_5.gemfile +8 -0
- data/lib/safe_target_blank/url_helper.rb +6 -3
- data/lib/safe_target_blank/version.rb +1 -1
- data/safe_target_blank.gemspec +1 -0
- metadata +20 -4
- data/CODE_OF_CONDUCT.md +0 -49
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2e7638db730f7b99a04a6b1faf2cdcaeb725a5b51bf2600aebeb6b1d7fdc71c9
|
|
4
|
+
data.tar.gz: 3005292cd91831112836e7b194162d6b979bffb97791b8d7b9accad0eaf10278
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d33a4aa5cf89570a8a0656e69b1998728264f94661424ab8a132577e6d406bf831ca648e9b41c80d61a457d1095cffa637fb23437b5e08c00e9e395e172de5a
|
|
7
|
+
data.tar.gz: 4ad8e6397a57671cde91afe5205eea5ba64ed51e880f5f08b18493b84e26e66676a8a452e45e8ec54e5e665811085348afc4bfdf569aec8834e4b58f9e3f3ffc
|
data/.travis.yml
CHANGED
data/Appraisals
ADDED
data/README.md
CHANGED
|
@@ -20,14 +20,14 @@ Add this line to your application's Gemfile:
|
|
|
20
20
|
Now each time you use the `link_to` helper with `target="_blank"`, `rel="noopener noreferrer"` will be added.
|
|
21
21
|
|
|
22
22
|
```ruby
|
|
23
|
-
link_to 'Safe', 'safe.io',
|
|
23
|
+
link_to 'Safe', 'safe.io', target: :_blank
|
|
24
24
|
#=> '<a target="_blank" rel="noopener noreferrer" href="safe.io">Safe</a>'
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
You can opt out with `opener` and `referrer` options.
|
|
28
28
|
|
|
29
29
|
```ruby
|
|
30
|
-
link_to 'Safe', 'safe.io',
|
|
30
|
+
link_to 'Safe', 'safe.io', target: :_blank, referrer: true
|
|
31
31
|
#=> '<a target="_blank" rel="noopener" href="safe.io">Safe</a>'
|
|
32
32
|
```
|
|
33
33
|
|
|
@@ -35,14 +35,17 @@ Or disable it globally.
|
|
|
35
35
|
|
|
36
36
|
```ruby
|
|
37
37
|
SafeTargetBlank.opener = true
|
|
38
|
-
link_to 'Safe', 'safe.io',
|
|
38
|
+
link_to 'Safe', 'safe.io', target: :_blank
|
|
39
39
|
#=> '<a target="_blank" rel="noreferrer" href="safe.io">Safe</a>'
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Contributing
|
|
43
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
|
43
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
|
44
|
+
Then, run `rake` to run the tests.
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
47
|
+
|
|
48
|
+
Bug reports and pull requests are welcome on GitHub.
|
|
46
49
|
|
|
47
50
|
## License
|
|
48
51
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
require 'bundler/gem_tasks'
|
|
2
2
|
require 'rspec/core/rake_task'
|
|
3
|
+
require 'appraisal'
|
|
3
4
|
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
if !ENV['APPRAISAL_INITIALIZED'] && !ENV['TRAVIS']
|
|
8
|
+
task default: :appraisal
|
|
9
|
+
else
|
|
10
|
+
task default: :spec
|
|
11
|
+
end
|
data/bin/setup
CHANGED
|
@@ -19,17 +19,20 @@ module ActionView
|
|
|
19
19
|
rel = link_to_rel_from_html_options(html_options)
|
|
20
20
|
rel.push('noopener') if !SafeTargetBlank.opener && !link_to_option_enabled?(html_options, 'opener')
|
|
21
21
|
rel.push('noreferrer') if !SafeTargetBlank.referrer && !link_to_option_enabled?(html_options, 'referrer')
|
|
22
|
-
rel.
|
|
22
|
+
rel.map(&:presence).compact.uniq.join(' ')
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def convert_options_to_data_attributes(options, html_options)
|
|
26
26
|
if html_options
|
|
27
27
|
html_options = html_options.stringify_keys
|
|
28
|
-
|
|
28
|
+
if link_to_target_blank?(html_options)
|
|
29
|
+
rel = link_to_target_blank_default_rel(html_options).presence
|
|
30
|
+
html_options['rel'] = rel if rel
|
|
31
|
+
end
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
original_convert_options_to_data_attributes(options, html_options)
|
|
32
35
|
end
|
|
33
36
|
end
|
|
34
37
|
end
|
|
35
|
-
end
|
|
38
|
+
end
|
data/safe_target_blank.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: safe_target_blank
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Venezia
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0.8'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: appraisal
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2.1'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2.1'
|
|
83
97
|
description: Adds noopener and noreferrer to target blank links in a Rails application.
|
|
84
98
|
email:
|
|
85
99
|
- veneziajeremy@gmail.com
|
|
@@ -90,13 +104,15 @@ files:
|
|
|
90
104
|
- ".gitignore"
|
|
91
105
|
- ".rspec"
|
|
92
106
|
- ".travis.yml"
|
|
93
|
-
-
|
|
107
|
+
- Appraisals
|
|
94
108
|
- Gemfile
|
|
95
109
|
- LICENSE.txt
|
|
96
110
|
- README.md
|
|
97
111
|
- Rakefile
|
|
98
112
|
- bin/console
|
|
99
113
|
- bin/setup
|
|
114
|
+
- gemfiles/rails_4.gemfile
|
|
115
|
+
- gemfiles/rails_5.gemfile
|
|
100
116
|
- lib/safe_target_blank.rb
|
|
101
117
|
- lib/safe_target_blank/url_helper.rb
|
|
102
118
|
- lib/safe_target_blank/version.rb
|
|
@@ -121,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
121
137
|
version: '0'
|
|
122
138
|
requirements: []
|
|
123
139
|
rubyforge_project:
|
|
124
|
-
rubygems_version: 2.
|
|
140
|
+
rubygems_version: 2.7.9
|
|
125
141
|
signing_key:
|
|
126
142
|
specification_version: 4
|
|
127
143
|
summary: Adds noopener and noreferrer to target blank links in a Rails application.
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# Contributor Code of Conduct
|
|
2
|
-
|
|
3
|
-
As contributors and maintainers of this project, and in the interest of
|
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
-
|
|
8
|
-
We are committed to making participation in this project a harassment-free
|
|
9
|
-
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
-
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
-
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
-
|
|
13
|
-
Examples of unacceptable behavior by participants include:
|
|
14
|
-
|
|
15
|
-
* The use of sexualized language or imagery
|
|
16
|
-
* Personal attacks
|
|
17
|
-
* Trolling or insulting/derogatory comments
|
|
18
|
-
* Public or private harassment
|
|
19
|
-
* Publishing other's private information, such as physical or electronic
|
|
20
|
-
addresses, without explicit permission
|
|
21
|
-
* Other unethical or unprofessional conduct
|
|
22
|
-
|
|
23
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
-
threatening, offensive, or harmful.
|
|
28
|
-
|
|
29
|
-
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
-
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
-
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
-
Conduct may be permanently removed from the project team.
|
|
33
|
-
|
|
34
|
-
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
-
when an individual is representing the project or its community.
|
|
36
|
-
|
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
-
reported by contacting a project maintainer at veneziajeremy@gmail.com. All
|
|
39
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
-
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
-
incident.
|
|
43
|
-
|
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
-
version 1.3.0, available at
|
|
46
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
-
|
|
48
|
-
[homepage]: http://contributor-covenant.org
|
|
49
|
-
[version]: http://contributor-covenant.org/version/1/3/0/
|