Merge pull request #12165 from Bo98/http-mirror
rubocops/urls: allow plain HTTP mirrors
This commit is contained in:
		
						commit
						1909d89d00
					
				@ -35,14 +35,14 @@ module RuboCop
 | 
			
		||||
      # @param urls [Array] url/mirror method call nodes
 | 
			
		||||
      # @param regex [Regexp] pattern to match URLs
 | 
			
		||||
      def audit_urls(urls, regex)
 | 
			
		||||
        urls.each do |url_node|
 | 
			
		||||
        urls.each_with_index do |url_node, index|
 | 
			
		||||
          url_string_node = parameters(url_node).first
 | 
			
		||||
          url_string = string_content(url_string_node)
 | 
			
		||||
          match_object = regex_match_group(url_string_node, regex)
 | 
			
		||||
          next unless match_object
 | 
			
		||||
 | 
			
		||||
          offending_node(url_string_node.parent)
 | 
			
		||||
          yield match_object, url_string
 | 
			
		||||
          yield match_object, url_string, index
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -83,8 +83,14 @@ module RuboCop
 | 
			
		||||
                                                 %r{^http://(?:[^/]*\.)?archive\.org},
 | 
			
		||||
                                                 %r{^http://(?:[^/]*\.)?freedesktop\.org},
 | 
			
		||||
                                                 %r{^http://(?:[^/]*\.)?mirrorservice\.org/}])
 | 
			
		||||
          audit_urls(urls, http_to_https_patterns) do |_, url|
 | 
			
		||||
            problem "Please use https:// for #{url}"
 | 
			
		||||
          audit_urls(urls, http_to_https_patterns) do |_, url, index|
 | 
			
		||||
            # It's fine to have a plain HTTP mirror further down the mirror list.
 | 
			
		||||
            https_url = url.dup.insert(4, "s")
 | 
			
		||||
            https_index = nil
 | 
			
		||||
            audit_urls(urls, https_url) do |_, _, found_https_index|
 | 
			
		||||
              https_index = found_https_index
 | 
			
		||||
            end
 | 
			
		||||
            problem "Please use https:// for #{url}" if !https_index || https_index > index
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          apache_mirror_pattern = %r{^https?://(?:[^/]*\.)?apache\.org/dyn/closer\.(?:cgi|lua)\?path=/?(.*)}i
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user