@@ -53,6 +53,25 @@ def analyze_path(spec_path)
53
53
# @!group Private helpers
54
54
#-----------------------------------------------------------------------#
55
55
56
+ # Resolve potential redirects and return the final URL.
57
+ #
58
+ # @return [string]
59
+ #
60
+ def get_actual_url ( url )
61
+ loop do
62
+ require 'rest'
63
+ response = REST . head ( url )
64
+
65
+ if response . status_code == 301
66
+ url = response . headers [ 'location' ] . first
67
+ else
68
+ break
69
+ end
70
+ end
71
+
72
+ url
73
+ end
74
+
56
75
# Checks whether the source of the proposed specification is different
57
76
# from the one of the reference specification.
58
77
#
@@ -68,11 +87,15 @@ def check_spec_source_change(spec, errors)
68
87
source = spec . source . values_at ( *keys ) . compact . first
69
88
old_source = reference_spec ( spec ) . source . values_at ( *keys ) . compact . first
70
89
unless source == old_source
71
- message = "The source of the spec doesn't match with the recorded "
72
- message << "ones. Source: `#{ source } `. Previous: `#{ old_source } `.\n "
73
- message << 'Please contact the specs repo maintainers if the'
74
- message << 'library changed location.'
75
- errors << message
90
+ source = get_actual_url ( source )
91
+ old_source = get_actual_url ( old_source )
92
+ unless source == old_source
93
+ message = "The source of the spec doesn't match with the recorded "
94
+ message << "ones. Source: `#{ source } `. Previous: `#{ old_source } `.\n "
95
+ message << 'Please contact the specs repo maintainers if the'
96
+ message << 'library changed location.'
97
+ errors << message
98
+ end
76
99
end
77
100
end
78
101
0 commit comments