html-proofer 4.0.1 → 4.1.0

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: 4c86b30d36446c4e7513915f860d356094394893184e451050133d8db0051588
4
- data.tar.gz: dea3274188458eec8e625e3d0e891cb383e9b533cf8f378a9348a1baf724f1e3
3
+ metadata.gz: c827c0b89b31ad51e1a4b177f190bdcbbb8f8fd933f235420be60da28e43cfb6
4
+ data.tar.gz: e47a4bf7944efc46622762720036c846c1ccb82acf339d99a93d7fade05eb1d9
5
5
  SHA512:
6
- metadata.gz: 128ba50160a450747d9f7085ac6cea6231c6ec962a9d4b159df9f882682ec78396b5f2ca86264a69b1cbb0b3c28b2e96e2fb93f7e398ee60cee7d4a49b9c6b65
7
- data.tar.gz: 323474cfa12ccadc4254f7dab7d035b8569fad92c4337d5946776b14a10dd30213849ed278ad9d3b314dcc20c93c5af78071b9acdaaee6635b4070a88497eb87
6
+ metadata.gz: c4b46613b516b0fbbaf52747d812dd390598b2bd3db6d45e342d2946ed012a7da2d47f36a0bae9a7c8b09fd484d7d0ecf2e4d12714f1044bb0ef2cfd5bd1d6da
7
+ data.tar.gz: '005058a0df180ce5619c2733438189842645840e1b94b6209bd3b2b6751b6cdd5f30b2adaa4aaed1e797e1332cfaf98388d54e06bf4497f5eb6f9796be71a1d8'
data/bin/htmlproofer CHANGED
@@ -24,7 +24,7 @@ Mercenary.program(:htmlproofer) do |p|
24
24
  p.option 'check_sri', '--check-sri', 'Check that `<link>` and `<script>` external resources use SRI (default: `false`).'
25
25
  p.option 'directory_index_file', '--directory-index-file <filename>', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
26
26
  p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker (default: `false`)'
27
- p.option 'enforce_https', '--enforce-https', 'Fails a link if it\'s not marked as `https` (default: `true`).'
27
+ p.option 'enforce_https', '--enforce-https <false>', String, 'Fails a link if it\'s not marked as `https` (default: `true`).'
28
28
  p.option 'extensions', '--extensions ext1,[ext2,...[', Array, 'A comma-separated list of Strings indicating the file extensions you would like to check (including the dot) (default: `.html`)'
29
29
  p.option 'ignore_empty_alt', '--ignore-empty-alt', ' If `true`, ignores images with empty/missing alt tags (in other words, `<img alt>` and `<img alt="">` are valid; set this to `false` to flag those)'
30
30
  p.option 'ignore_files', '--ignore-files file1,[file2,...]', Array, 'A comma-separated list of Strings or RegExps containing file paths that are safe to ignore'
@@ -67,6 +67,8 @@ Mercenary.program(:htmlproofer) do |p|
67
67
  end
68
68
  end
69
69
 
70
+ options[:enforce_https] = false if opts['enforce_https'] == "false"
71
+
70
72
  options[:log_level] = opts['log_level'].to_sym unless opts['log_level'].nil?
71
73
 
72
74
  options[:typhoeus] = HTMLProofer::Configuration.parse_json_option('typhoeus', opts['typhoeus'], symbolize_names: false) unless opts['typhoeus'].nil?
@@ -20,12 +20,21 @@ module HTMLProofer
20
20
  add_failure("image has no src or srcset attribute", line: @img.line, content: @img.content)
21
21
  elsif @img.url.remote?
22
22
  add_to_external_urls(@img.url, @img.line)
23
- elsif !@img.url.exists? && !@img.multiple_srcsets?
23
+ elsif !@img.url.exists? && !@img.multiple_srcsets? && !@img.multiple_sizes?
24
24
  add_failure("internal image #{@img.url.raw_attribute} does not exist", line: @img.line,
25
25
  content: @img.content)
26
26
  elsif @img.multiple_srcsets?
27
- srcsets = @img.srcset.split(",").map(&:strip)
28
- srcsets.each do |srcset|
27
+ @img.srcsets.each do |srcset|
28
+ srcset_url = HTMLProofer::Attribute::Url.new(@runner, srcset, base_url: @img.base_url)
29
+
30
+ if srcset_url.remote?
31
+ add_to_external_urls(srcset_url.url, @img.line)
32
+ elsif !srcset_url.exists?
33
+ add_failure("internal image #{srcset} does not exist", line: @img.line, content: @img.content)
34
+ end
35
+ end
36
+ elsif @img.multiple_sizes?
37
+ @img.srcsets_wo_sizes.each do |srcset|
29
38
  srcset_url = HTMLProofer::Attribute::Url.new(@runner, srcset, base_url: @img.base_url)
30
39
 
31
40
  if srcset_url.remote?
@@ -84,6 +84,28 @@ module HTMLProofer
84
84
  !blank?(srcset) && srcset.split(",").size > 1
85
85
  end
86
86
 
87
+ def srcsets
88
+ return nil if blank?(srcset)
89
+
90
+ srcset.split(",").map(&:strip)
91
+ end
92
+
93
+ def multiple_sizes?
94
+ return false if blank?(srcsets)
95
+
96
+ srcsets.any? do |srcset|
97
+ !blank?(srcset) && srcset.split(" ").size > 1
98
+ end
99
+ end
100
+
101
+ def srcsets_wo_sizes
102
+ return nil if blank?(srcsets)
103
+
104
+ srcsets.map do |srcset|
105
+ srcset.split(" ").first
106
+ end
107
+ end
108
+
87
109
  def ignore?
88
110
  return true if @node.attributes["data-proofer-ignore"]
89
111
  return true if ancestors_ignorable?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTMLProofer
4
- VERSION = "4.0.1"
4
+ VERSION = "4.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-proofer
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-12 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable