crawlscope 0.11.1 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b762eff7cebfcc183918035d2f35516378192355af00750936b9eb20bc0f5f4
4
- data.tar.gz: f275d0a2c99ad2e7774c6dc9247e4b8d6963c55bcc97806a9204dbb685c56739
3
+ metadata.gz: e8f15e4f938806d9a6859dcf818302fe7f35321c360e70e1be6451d4e5af96cc
4
+ data.tar.gz: 85a405a9ca3b1b25655ec3aa9c72dcc1fd3c51fc2303b3831bb7c88ea1e597de
5
5
  SHA512:
6
- metadata.gz: 1fd13e485bc833f324a6b65bf897d7dc062ca46d7553df9bcfe682d367ddaf790ee47c047ed92d6068b1b90b21fbf55748278730f8e26720cf83a5ae9ef31810
7
- data.tar.gz: 235ae91febd74f0afcf4dcbaaff0dd15226da2923a214247560c644b2b22bdbbdb59171b2c7b49d9a124de1aafec7dbeb68bd0d3d8b88af74d0dd263a1fbde82
6
+ metadata.gz: d3c1f8eef1e50c42f61edf897487ff3c60b071d76757bf2a0a2697c56da3e1fc8625e484f545eb42f522f44a7bf4d4b77850b8c0225e77087fb5345eeee34cd3
7
+ data.tar.gz: 16a78c6d5694a3a5ea31ec2011eeec41b74fe4b74fbed9d27264d4c86f353412c688eacbb7a345cd9e88b2430889763223762fb6743cd59d8587e434261f7539
data/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.11.2] - 2026-11-29
9
+
10
+
11
+ ### Fixed
12
+
13
+ - follow pagination and consolidate link findings
14
+
15
+
16
+
8
17
  ## [0.11.1] - 2026-11-28
9
18
 
10
19
 
data/README.md CHANGED
@@ -150,6 +150,19 @@ characters for an Article JSON-LD `headline`. These are separate Crawlscope
150
150
  validation limits for separate fields. Server timing lists pages only when the
151
151
  reported duration exceeds 50 ms; aggregate statistics include all responses.
152
152
 
153
+ For a directory that uses query parameters on pagination links, set
154
+ `CRAWLSCOPE_PAGINATION_PARAMETERS` to a comma-separated list of public
155
+ parameter names, such as `page` or `after`. Validation follows same-path,
156
+ same-origin query links marked with `rel="next"` when the links rule is
157
+ enabled. These pages supply link evidence and count toward fetched pages.
158
+ Validation caps this traversal at 2,500 additional pages. The standalone link
159
+ map also respects its follow-depth and page limits. Allowlisted query values
160
+ can appear in the output, so only enable parameters with public values.
161
+
162
+ Set `CRAWLSCOPE_DESCRIPTION_MIN_LENGTH` or `CRAWLSCOPE_MIN_VISIBLE_WORDS`
163
+ to set the corresponding minimum. A value of zero disables that length
164
+ warning. The metadata rule still reports missing descriptions.
165
+
153
166
  ## Ruby Usage
154
167
 
155
168
  ```ruby
data/UPGRADE.md CHANGED
@@ -37,6 +37,19 @@ in the README; the shared workflow does not inherit another gem's permission.
37
37
 
38
38
  ## Next Release
39
39
 
40
+ ### Paginated link evidence
41
+
42
+ Set `config.pagination_parameters` or
43
+ `CRAWLSCOPE_PAGINATION_PARAMETERS` to the public query parameter names
44
+ used on links marked `rel="next"`. With the links rule enabled, opt-in
45
+ validation includes the additional fetches in `Result.pages`. Use
46
+ `Result.urls` for the sitemap inventory. The standalone link map includes
47
+ these links subject to its follow limits.
48
+
49
+ A broken sitemap URL now yields one `unexpected_status` issue with
50
+ `details[:source_urls]` when it also has broken incoming links. A page
51
+ with zero incoming links is reported once as an orphan.
52
+
40
53
  ### Validation console output
41
54
 
42
55
  `crawlscope validate` and `crawlscope:validate` now show a link map summary
@@ -344,7 +344,8 @@ module Crawlscope
344
344
  end
345
345
 
346
346
  def task(link_map: true)
347
- @task ||= Run.new(configuration: @configuration, reporter: Reporter.new(io: @out, link_map: link_map, invocation: @invocation))
347
+ @task ||= Run.new(configuration: @configuration, reporter: Reporter.new(io: @out, link_map: link_map,
348
+ invocation: @invocation, pagination_parameters: @configuration.pagination_parameters))
348
349
  end
349
350
  end
350
351
  end
@@ -60,6 +60,14 @@ module Crawlscope
60
60
  value.nil? ? $stdout : value
61
61
  end
62
62
 
63
+ attr_writer :description_min_length, :min_visible_words, :pagination_parameters
64
+
65
+ def pagination_parameters
66
+ value = resolve(@pagination_parameters)
67
+ value ||= ENV["CRAWLSCOPE_PAGINATION_PARAMETERS"].to_s.split(",")
68
+ Array(value).map(&:strip).reject(&:empty?).uniq
69
+ end
70
+
63
71
  def profile_token
64
72
  resolve(@profile_token) || ENV["CRAWLSCOPE_PROFILE_TOKEN"]
65
73
  end
@@ -79,7 +87,9 @@ module Crawlscope
79
87
  value = resolve(@rule_registry)
80
88
  return value unless value.nil?
81
89
 
82
- RuleRegistry.default(site_name: site_name, required_types: required_structured_data_types)
90
+ RuleRegistry.default(site_name: site_name, required_types: required_structured_data_types,
91
+ description_min_length: threshold(@description_min_length, "CRAWLSCOPE_DESCRIPTION_MIN_LENGTH", Rules::Metadata::DESCRIPTION_MIN_LENGTH),
92
+ min_visible_words: threshold(@min_visible_words, "CRAWLSCOPE_MIN_VISIBLE_WORDS", Rules::ContentQuality::MIN_VISIBLE_WORDS))
83
93
  end
84
94
 
85
95
  def audit(base_url: self.base_url, sitemap_path: self.sitemap_path, rule_names: nil)
@@ -98,6 +108,7 @@ module Crawlscope
98
108
  concurrency: concurrency,
99
109
  fetch_executor: fetch_executor,
100
110
  network_idle_timeout_seconds: network_idle_timeout_seconds,
111
+ pagination_parameters: pagination_parameters,
101
112
  profile_token: profile_token,
102
113
  renderer: renderer,
103
114
  timeout_seconds: timeout_seconds,
@@ -139,6 +150,18 @@ module Crawlscope
139
150
  value.respond_to?(:call) ? value.call : value
140
151
  end
141
152
 
153
+ def threshold(value, key, default)
154
+ raw = resolve(value) || ENV[key]
155
+ return default if raw.nil?
156
+
157
+ number = raw.is_a?(Integer) ? raw : Integer(raw, 10)
158
+ return number unless number.negative?
159
+
160
+ raise ArgumentError
161
+ rescue ArgumentError, TypeError
162
+ raise ConfigurationError, "#{key} must be a non-negative integer"
163
+ end
164
+
142
165
  def positive_integer(value, default:, name:)
143
166
  return default if value.nil?
144
167
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Crawlscope
4
4
  class Crawl
5
- def initialize(base_url:, sitemap_path:, rules:, schema_registry:, browser_factory: nil, concurrency: Configuration::DEFAULT_CONCURRENCY, fetch_executor: nil, network_idle_timeout_seconds: Configuration::DEFAULT_BROWSER_NETWORK_IDLE_TIMEOUT_SECONDS, profile_token: nil, renderer: :http, scroll_page: Configuration::DEFAULT_BROWSER_SCROLL_PAGE, timeout_seconds: Configuration::DEFAULT_TIMEOUT_SECONDS, allowed_statuses: Configuration::DEFAULT_ALLOWED_STATUSES)
5
+ def initialize(base_url:, sitemap_path:, rules:, schema_registry:, browser_factory: nil, concurrency: Configuration::DEFAULT_CONCURRENCY, fetch_executor: nil, network_idle_timeout_seconds: Configuration::DEFAULT_BROWSER_NETWORK_IDLE_TIMEOUT_SECONDS, pagination_parameters: [], profile_token: nil, renderer: :http, scroll_page: Configuration::DEFAULT_BROWSER_SCROLL_PAGE, timeout_seconds: Configuration::DEFAULT_TIMEOUT_SECONDS, allowed_statuses: Configuration::DEFAULT_ALLOWED_STATUSES)
6
6
  @base_url = base_url
7
7
  @sitemap_path = sitemap_path
8
8
  @rules = Array(rules)
@@ -10,6 +10,7 @@ module Crawlscope
10
10
  @browser_factory = browser_factory
11
11
  @concurrency = concurrency
12
12
  @network_idle_timeout_seconds = network_idle_timeout_seconds
13
+ @pagination_parameters = pagination_parameters
13
14
  @profile_token = profile_token
14
15
  @renderer = renderer.to_sym
15
16
  @fetch_executor = fetch_executor || default_fetch_executor
@@ -24,21 +25,23 @@ module Crawlscope
24
25
  urls = sitemap_urls
25
26
 
26
27
  @page_fetcher = page
27
- pages = Crawler.new(page_fetcher: @page_fetcher, concurrency: @concurrency, fetch_executor: @fetch_executor).call(urls)
28
+ crawler = Crawler.new(page_fetcher: @page_fetcher, concurrency: @concurrency, fetch_executor: @fetch_executor)
29
+ pages = crawler.call(urls)
28
30
  issues = IssueCollection.new
29
31
 
30
- collect(pages, issues)
32
+ pagination = pagination_pages(crawler, pages, issues)
31
33
  @target_resolver = Crawling::TargetResolver.new(
32
- base_url: @base_url, pages: pages,
33
- crawler: Crawler.new(page_fetcher: @page_fetcher, concurrency: @concurrency, fetch_executor: @fetch_executor)
34
+ base_url: @base_url, pages: pages + pagination, crawler: crawler
34
35
  )
35
- scan(urls, pages, issues)
36
+ pagination_sources = pagination.select { |page| page.status == 200 && !redirected?(page) }
37
+ scan(urls, pages, pagination_sources, issues)
38
+ issues = collect(pages, issues)
36
39
 
37
40
  Result.new(
38
41
  base_url: @base_url,
39
42
  sitemap_path: @sitemap_path,
40
43
  urls: urls,
41
- pages: pages,
44
+ pages: pages + pagination,
42
45
  issues: issues
43
46
  )
44
47
  ensure
@@ -100,20 +103,46 @@ module Crawlscope
100
103
  end
101
104
 
102
105
  def collect(pages, issues)
106
+ reported = issues.filter_map do |issue|
107
+ [issue.url, issue] if issue.code == :broken_internal_link
108
+ end.to_h
109
+ combined = Set.new
110
+ result = IssueCollection.new
103
111
  pages.each do |page|
104
112
  if page.error
105
- issues.add(code: :fetch_failed, severity: :error, category: :crawl, url: page.url, message: page.error, details: {})
113
+ result.add(code: :fetch_failed, severity: :error, category: :crawl, url: page.url, message: page.error, details: {})
106
114
  elsif !@allowed_statuses.include?(page.status)
107
- issues.add(code: :unexpected_status, severity: :error, category: :crawl, url: page.url, message: "HTTP #{page.status}", details: {status: page.status})
115
+ link = reported[page.normalized_url]
116
+ details = {status: page.status}
117
+ if link && link.details[:status] == page.status
118
+ details.merge!(link.details)
119
+ combined.add(link)
120
+ end
121
+ result.add(code: :unexpected_status, severity: :error, category: :crawl, url: page.url, message: "HTTP #{page.status}", details: details)
108
122
  elsif redirected?(page)
109
- issues.add(code: :sitemap_redirect_url, severity: :warning, category: :sitemaps, url: page.url, message: "sitemap URL redirects to #{page.final_url}", details: {final_url: page.final_url, status: page.status})
123
+ result.add(code: :sitemap_redirect_url, severity: :warning, category: :sitemaps, url: page.url, message: "sitemap URL redirects to #{page.final_url}", details: {final_url: page.final_url, status: page.status})
110
124
  end
111
125
  end
126
+ issues.each { |issue| result.add(issue) unless combined.include?(issue) }
127
+ result
112
128
  end
113
129
 
114
- def scan(urls, pages, issues)
130
+ def pagination_pages(crawler, pages, issues)
131
+ return [] if @pagination_parameters.empty? || !@rules.any?(Rules::Links)
132
+
133
+ pagination = Crawling::Pagination.new(crawler: crawler, parameters: @pagination_parameters)
134
+ additional = pagination.call(pages)
135
+ if pagination.limited
136
+ issues.add(code: :pagination_limit, severity: :notice, category: :links, url: @base_url,
137
+ message: "Link coverage is partial: pagination exceeded #{Crawling::Pagination::MAX_PAGES} pages", details: {})
138
+ end
139
+ additional
140
+ end
141
+
142
+ def scan(urls, pages, pagination, issues)
115
143
  @rules.each do |rule|
116
- rule.call(urls: urls, pages: pages, issues: issues, context: context)
144
+ sources = rule.is_a?(Rules::Links) ? pages + pagination : pages
145
+ rule.call(urls: urls, pages: sources, issues: issues, context: context)
117
146
  end
118
147
  end
119
148
 
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crawlscope
4
+ module Crawling
5
+ class Pagination
6
+ MAX_PAGES = 2_500
7
+ NEXT_LINKS = 'a[rel~="next"][href]:not([rel~="nofollow"])'
8
+
9
+ attr_reader :limited
10
+
11
+ def self.target(href, source:, parameters:)
12
+ return if parameters.empty? || href.to_s.empty? || href.bytesize > 2_048
13
+
14
+ target = URI.join(source, href)
15
+ return unless target.query && !target.userinfo && RequestHeaders.same_origin?(target.to_s, base_url: source)
16
+ return unless Url.path(target.to_s) == Url.path(source)
17
+ keys = URI.decode_www_form(target.query).map(&:first)
18
+ return if keys.empty? || keys.uniq.size != keys.size
19
+ return unless keys.all? { |key| parameters.include?(key) }
20
+
21
+ Url.normalize(target.to_s, base_url: source)
22
+ rescue URI::Error, ArgumentError
23
+ nil
24
+ end
25
+
26
+ def initialize(crawler:, parameters:)
27
+ @crawler = crawler
28
+ @parameters = parameters
29
+ @limited = false
30
+ end
31
+
32
+ def call(pages)
33
+ seen = pages.map(&:normalized_url).to_set
34
+ additional = []
35
+ frontier = pages
36
+
37
+ loop do
38
+ urls = frontier.flat_map { |page| next_urls(page) }.select { |url| seen.add?(url) }
39
+ break if urls.empty?
40
+
41
+ remaining = MAX_PAGES - additional.size
42
+ @limited ||= urls.size > remaining
43
+ break if remaining.zero?
44
+
45
+ frontier = @crawler.call(urls.take(remaining))
46
+ additional.concat(frontier)
47
+ end
48
+
49
+ additional
50
+ end
51
+
52
+ private
53
+
54
+ def next_urls(page)
55
+ return [] unless page.status == 200 && page.html? && page.normalized_url == page.normalized_final_url
56
+
57
+ page.doc.css(NEXT_LINKS).filter_map do |node|
58
+ self.class.target(node["href"], source: page.normalized_url, parameters: @parameters)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -10,8 +10,8 @@ module Crawlscope
10
10
  def initialize(base_url:, sitemap_path: nil, roots: nil, inventory: [], manifest: {}, paths: ["/"], exclude_paths: [],
11
11
  max_pages: 10_000, max_edges: 100_000, follow_limit: 0, follow_depth: 3,
12
12
  concurrency: Configuration::DEFAULT_CONCURRENCY, fetch_executor: Configuration::DEFAULT_FETCH_EXECUTOR,
13
- timeout_seconds: Configuration::DEFAULT_TIMEOUT_SECONDS)
14
- @scope = Scope.new(base_url, paths: paths, exclude_paths: exclude_paths)
13
+ timeout_seconds: Configuration::DEFAULT_TIMEOUT_SECONDS, pagination_parameters: [])
14
+ @scope = Scope.new(base_url, paths: paths, exclude_paths: exclude_paths, pagination_parameters: pagination_parameters)
15
15
  @sitemap_path = sitemap_path
16
16
  @roots = roots.nil? ? ["#{@scope.origin}/"] : Array(roots)
17
17
  @inventory = inventory
@@ -52,13 +52,13 @@ module Crawlscope
52
52
  roots = prepare_graph
53
53
  sitemap = scoped_urls(urls, "sitemap")
54
54
  pages.each do |page|
55
- url, reason = @scope.resolve(page.url)
55
+ url, reason = @scope.resolve(page.url, pagination: true)
56
56
  if reason
57
57
  @exclusions["page:#{reason}"] += 1
58
58
  next
59
59
  end
60
60
 
61
- final, reason = @scope.resolve(page.final_url || page.url)
61
+ final, reason = @scope.resolve(page.final_url || page.url, pagination: true)
62
62
  if reason
63
63
  @responses[url] = {coverage: reason}
64
64
  next
@@ -24,12 +24,13 @@ module Crawlscope
24
24
  href = node["href"].strip
25
25
  next if href.empty? || href.start_with?("#")
26
26
 
27
- target, reason = @scope.resolve(href, base: base)
27
+ rel = node["rel"].to_s.downcase.split.uniq.sort & %w[alternate author bookmark external help license next nofollow noopener noreferrer prev search sponsored tag ugc]
28
+ continuation = @scope.pagination_target(href, source: source) if rel.include?("next")
29
+ target, reason = @scope.resolve(continuation || href, base: base, pagination: !continuation.nil?)
28
30
  @exclusions["link:#{reason}"] += 1 if reason
29
31
  next unless target || reason == "query"
30
32
 
31
33
  position = position(node)
32
- rel = node["rel"].to_s.downcase.split.uniq.sort & %w[alternate author bookmark external help license next nofollow noopener noreferrer prev search sponsored tag ugc]
33
34
  yield({
34
35
  source_url: source, raw_href: href.split(/[?#]/, 2).first, target_url: target,
35
36
  anchor_text: text(node.text), image_alt: text(node.css("img[alt]").map { |image| image["alt"] }.join(" ")),
@@ -7,7 +7,7 @@ module Crawlscope
7
7
 
8
8
  attr_reader :origin
9
9
 
10
- def initialize(base_url, paths:, exclude_paths:)
10
+ def initialize(base_url, paths:, exclude_paths:, pagination_parameters: [])
11
11
  base = URI.parse(base_url.to_s)
12
12
  unless base.is_a?(URI::HTTP) && base.host && !base.userinfo && !base.query && !base.fragment
13
13
  raise ConfigurationError, "Link map requires a public HTTP(S) base URL without credentials, query, or fragment"
@@ -17,11 +17,12 @@ module Crawlscope
17
17
  @link_scope = Rules::Links::Scope.new
18
18
  @paths = path_prefixes(paths)
19
19
  @exclude_paths = path_prefixes(exclude_paths)
20
+ @pagination_parameters = pagination_parameters
20
21
  rescue URI::Error
21
22
  raise ConfigurationError, "Invalid link map base URL"
22
23
  end
23
24
 
24
- def resolve(value, base: "#{origin}/", control: false)
25
+ def resolve(value, base: "#{origin}/", control: false, pagination: false)
25
26
  return [nil, "invalid_url"] unless value.is_a?(String) && !value.empty? && value.bytesize <= MAX_URL_BYTES
26
27
 
27
28
  uri = URI.join(base, value)
@@ -33,7 +34,7 @@ module Crawlscope
33
34
  path = self.class.normalize_path(uri.path)
34
35
  return [nil, "unsafe_path"] if path.match?(%r{(?:\A|/)\.{1,2}(?:/|\z)|//|;|%(?:[01][\da-f]|2[35f]|3[bf]|5c|7f)}i)
35
36
  return [nil, "outside_paths"] unless control || included_path?(path)
36
- return [nil, "query"] if uri.query
37
+ return [nil, "query"] if uri.query && (!pagination || !pagination_target(uri.to_s, source: uri.to_s))
37
38
 
38
39
  uri.path = path
39
40
  uri.fragment = nil
@@ -42,6 +43,10 @@ module Crawlscope
42
43
  [nil, "invalid_url"]
43
44
  end
44
45
 
46
+ def pagination_target(href, source:)
47
+ Crawling::Pagination.target(href, source: source, parameters: @pagination_parameters)
48
+ end
49
+
45
50
  def self.normalize_path(path)
46
51
  path.gsub(/%([\da-f]{2})/i) do |escape|
47
52
  byte = Regexp.last_match(1).hex.chr
@@ -4,10 +4,11 @@ module Crawlscope
4
4
  class Reporter
5
5
  GROUP_LABELS = Reporting::IssuePresenter::GROUP_LABELS
6
6
 
7
- def initialize(io:, link_map: true, invocation: :cli)
7
+ def initialize(io:, link_map: true, invocation: :cli, pagination_parameters: [])
8
8
  @io = io
9
9
  @link_map = link_map
10
10
  @invocation = invocation
11
+ @pagination_parameters = pagination_parameters
11
12
  end
12
13
 
13
14
  def report(result)
@@ -36,7 +37,8 @@ module Crawlscope
36
37
  private
37
38
 
38
39
  def report_link_map(result)
39
- report = LinkMap::Audit.new(base_url: result.base_url).from_pages(urls: result.urls, pages: result.pages)
40
+ report = LinkMap::Audit.new(base_url: result.base_url, pagination_parameters: @pagination_parameters)
41
+ .from_pages(urls: result.urls, pages: result.pages)
40
42
  @io.puts("")
41
43
  report.write_summary(@io, sitemap_path: result.sitemap_path, source: "HTML fetched during validation", invocation: @invocation)
42
44
  rescue ConfigurationError => error
@@ -30,7 +30,7 @@ module Crawlscope
30
30
  incomplete_open_graph_tags: "Missing Open Graph tags",
31
31
  title_too_long: "Title exceeds #{Rules::Metadata::TITLE_MAX_LENGTH} characters",
32
32
  meta_description_too_long: "Meta description exceeds #{Rules::Metadata::DESCRIPTION_MAX_LENGTH} characters",
33
- meta_description_too_short: "Meta description below #{Rules::Metadata::DESCRIPTION_MIN_LENGTH} characters",
33
+ meta_description_too_short: "Short meta description",
34
34
  duplicate_content_fingerprint: "Duplicate page text",
35
35
  near_duplicate_content: "Similar page text",
36
36
  near_duplicate_scan_skipped: "Similar-page check skipped"
@@ -85,8 +85,10 @@ module Crawlscope
85
85
  end
86
86
  when :unexpected_status
87
87
  return "HTTP #{details[:status]}" if details[:status]
88
- when :title_too_long, :meta_description_too_long, :meta_description_too_short
88
+ when :title_too_long, :meta_description_too_long
89
89
  return "#{details[:length]} characters" if details[:length]
90
+ when :meta_description_too_short
91
+ return "#{details[:length]} characters; minimum #{details[:minimum]}" if details[:minimum]
90
92
  when :broken_internal_link
91
93
  return "linked URL returns HTTP #{details[:status]}"
92
94
  when :unresolved_internal_link
@@ -9,14 +9,15 @@ module Crawlscope
9
9
  @default_codes = Array(default_codes).map(&:to_sym)
10
10
  end
11
11
 
12
- def self.default(site_name: nil, required_types: nil)
12
+ def self.default(site_name: nil, required_types: nil, description_min_length: Rules::Metadata::DESCRIPTION_MIN_LENGTH,
13
+ min_visible_words: Rules::ContentQuality::MIN_VISIBLE_WORDS)
13
14
  new(
14
15
  rules: [
15
16
  Rules::Indexability.new,
16
- Rules::Metadata.new(site_name: site_name),
17
+ Rules::Metadata.new(site_name: site_name, description_min_length: description_min_length),
17
18
  Rules::StructuredData.new(required_types: required_types),
18
19
  Rules::Uniqueness.new,
19
- Rules::ContentQuality.new,
20
+ Rules::ContentQuality.new(min_visible_words: min_visible_words),
20
21
  Rules::Links.new
21
22
  ],
22
23
  default_codes: %i[indexability metadata structured_data uniqueness content_quality links]
@@ -13,7 +13,7 @@ module Crawlscope
13
13
  end
14
14
 
15
15
  def call(urls:, pages:, issues:)
16
- sitemap_urls = urls.map { |url| Url.normalize(url, base_url: @base_url) }.compact
16
+ sitemap_urls = urls.filter_map { |url| Url.normalize(url, base_url: @base_url) }.to_set
17
17
  sitemap_pages = pages.select do |page|
18
18
  page.html? && sitemap_urls.include?(page.normalized_url) && page.normalized_url.to_s == page.normalized_final_url.to_s
19
19
  end
@@ -21,12 +21,14 @@ module Crawlscope
21
21
 
22
22
  canonical_entries = canonical_entries_for(sitemap_pages)
23
23
  @targets.resolve_all(canonical_entries.map { |entry| entry.fetch(:canonical_url) })
24
+ orphans = issues.select { |issue| issue.code == :orphan_page }.map(&:url).to_set
24
25
 
25
26
  canonical_entries.each do |entry|
26
27
  page = entry.fetch(:page)
27
28
  canonical_url = entry.fetch(:canonical_url)
28
29
  canonical_path = entry.fetch(:canonical_path)
29
- if canonical_path && !root_path?(canonical_path) && @graph.dofollow_count(canonical_url).zero?
30
+ if canonical_path && !root_path?(canonical_path) && !orphans.include?(canonical_url) &&
31
+ @graph.dofollow_count(canonical_url).zero?
30
32
  issues.add(
31
33
  code: :canonical_no_internal_inlinks,
32
34
  severity: :warning,
@@ -12,8 +12,9 @@ module Crawlscope
12
12
 
13
13
  attr_reader :code
14
14
 
15
- def initialize(site_name: nil)
15
+ def initialize(site_name: nil, description_min_length: DESCRIPTION_MIN_LENGTH)
16
16
  @site_name = site_name.to_s.strip
17
+ @description_min_length = description_min_length
17
18
  @code = :metadata
18
19
  end
19
20
 
@@ -116,8 +117,8 @@ module Crawlscope
116
117
 
117
118
  if description.empty?
118
119
  issues.add(code: :missing_meta_description, severity: :warning, category: :metadata, url: page.url, message: "missing meta description", details: {})
119
- elsif description.length < DESCRIPTION_MIN_LENGTH
120
- issues.add(code: :meta_description_too_short, severity: :warning, category: :metadata, url: page.url, message: "meta description: #{description.length} characters; minimum #{DESCRIPTION_MIN_LENGTH}", details: {length: description.length, minimum: DESCRIPTION_MIN_LENGTH})
120
+ elsif description.length < @description_min_length
121
+ issues.add(code: :meta_description_too_short, severity: :warning, category: :metadata, url: page.url, message: "meta description: #{description.length} characters; minimum #{@description_min_length}", details: {length: description.length, minimum: @description_min_length})
121
122
  elsif description.length > DESCRIPTION_MAX_LENGTH
122
123
  issues.add(code: :meta_description_too_long, severity: :warning, category: :metadata, url: page.url, message: "meta description: #{description.length} characters; maximum #{DESCRIPTION_MAX_LENGTH}", details: {length: description.length})
123
124
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Crawlscope
4
4
  class Run
5
- def initialize(configuration: Crawlscope.configuration, reporter: Reporter.new(io: configuration.output))
5
+ def initialize(configuration: Crawlscope.configuration, reporter: nil)
6
6
  @configuration = configuration
7
7
  @reporter = reporter
8
8
  end
@@ -16,7 +16,7 @@ module Crawlscope
16
16
  )
17
17
 
18
18
  result = crawl.call
19
- @reporter.report(result)
19
+ (@reporter ||= Reporter.new(io: @configuration.output, pagination_parameters: @configuration.pagination_parameters)).report(result)
20
20
  result
21
21
  end
22
22
 
@@ -43,6 +43,7 @@ module Crawlscope
43
43
  concurrency: @configuration.concurrency,
44
44
  fetch_executor: @configuration.fetch_executor,
45
45
  timeout_seconds: @configuration.timeout_seconds,
46
+ pagination_parameters: @configuration.pagination_parameters,
46
47
  **options
47
48
  ).call
48
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crawlscope
4
- VERSION = "0.11.1"
4
+ VERSION = "0.11.2"
5
5
  end
@@ -60,6 +60,51 @@ class CrawlscopeCrawlTest < Minitest::Test
60
60
  assert_empty result.issues.to_a
61
61
  end
62
62
 
63
+ def test_pagination_supplies_link_evidence_without_validating_the_pages_as_sitemap_entries
64
+ origin = "https://example.com"
65
+ paths = ["/", "/catalog", "/product"]
66
+ File.write(@sitemap_path, %(<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">#{paths.map { |path| "<url><loc>#{origin}#{path}</loc></url>" }.join}</urlset>))
67
+ headers = {"Content-Type" => "text/html"}
68
+ stub_request(:get, "#{origin}/").to_return(headers: headers, body: '<a href="/catalog">Catalog</a>')
69
+ stub_request(:get, "#{origin}/catalog").to_return(headers: headers,
70
+ body: '<a rel="next" href="?after=one#results">More</a>')
71
+ pagination = stub_request(:get, "#{origin}/catalog?after=one").to_return(headers: headers,
72
+ body: '<a rel="next" href="?after=two">More</a>')
73
+ stub_request(:get, "#{origin}/catalog?after=two").to_return(headers: headers,
74
+ body: '<a href="/product">Product</a><a rel="next" href="?after=one">Cycle</a>')
75
+ stub_request(:get, "#{origin}/product").to_return(headers: headers, body: "<h1>Product</h1>")
76
+
77
+ result = Crawlscope::Crawl.new(
78
+ base_url: origin, sitemap_path: @sitemap_path, pagination_parameters: ["after"],
79
+ rules: [Crawlscope::Rules::Links.new, Crawlscope::Rules::Metadata.new],
80
+ schema_registry: Crawlscope::SchemaRegistry.default
81
+ ).call
82
+ report = Crawlscope::LinkMap::Audit.new(base_url: origin, pagination_parameters: ["after"])
83
+ .from_pages(urls: result.urls, pages: result.pages)
84
+ product = report.to_h.fetch(:nodes).find { |node| node.fetch(:url) == "#{origin}/product" }
85
+
86
+ assert_equal 4, product.fetch(:click_depth)
87
+ assert_requested pagination, times: 1
88
+ assert result.issues.none? { |issue| issue.code == :orphan_page && issue.url == "#{origin}/product" }
89
+ assert result.issues.none? { |issue| issue.category == :metadata && issue.url.include?("?after=") }
90
+ end
91
+
92
+ def test_reports_a_broken_sitemap_url_once_and_keeps_its_link_source
93
+ origin = "https://example.com"
94
+ File.write(@sitemap_path, %(<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>#{origin}/</loc></url><url><loc>#{origin}/gone</loc></url></urlset>))
95
+ stub_request(:get, "#{origin}/").to_return(headers: {"Content-Type" => "text/html"}, body: '<a href="/gone">Gone</a>')
96
+ stub_request(:get, "#{origin}/gone").to_return(status: 404)
97
+
98
+ result = Crawlscope::Crawl.new(
99
+ base_url: origin, sitemap_path: @sitemap_path, rules: [Crawlscope::Rules::Links.new],
100
+ schema_registry: Crawlscope::SchemaRegistry.default
101
+ ).call
102
+
103
+ findings = result.issues.select { |issue| issue.url == "#{origin}/gone" }
104
+ assert_equal [:unexpected_status], findings.map(&:code)
105
+ assert_equal ["#{origin}/"], findings.first.details.fetch(:source_urls)
106
+ end
107
+
63
108
  def test_http_renderer_defaults_to_async_executor
64
109
  crawl = Crawlscope::Crawl.new(
65
110
  base_url: "https://example.com",
@@ -171,7 +171,8 @@ class CrawlscopeLinksRuleTest < Minitest::Test
171
171
  Crawlscope::Rules::Links.new.call(
172
172
  urls: ["https://example.com/guide", "https://example.com/pricing"],
173
173
  pages: [
174
- page(url: "https://example.com/guide", body: "<main><a href=\"/pricing\">Pricing</a></main>"),
174
+ page(url: "https://example.com/guide",
175
+ body: '<link rel="canonical" href="/guide"><main><a href="/pricing">Pricing</a></main>'),
175
176
  page(url: "https://example.com/pricing", body: "<main><p>Pricing</p></main>")
176
177
  ],
177
178
  issues: issues,
@@ -182,6 +183,7 @@ class CrawlscopeLinksRuleTest < Minitest::Test
182
183
  assert orphan_issue
183
184
  assert_includes issues.to_a.map(&:code), :low_dofollow_inlinks
184
185
  assert_equal "https://example.com/guide", orphan_issue.url
186
+ refute_includes issues.to_a.map(&:code), :canonical_no_internal_inlinks
185
187
  end
186
188
 
187
189
  def test_reports_pages_with_no_outgoing_internal_links
@@ -358,7 +358,7 @@ class CrawlscopeReporterTest < Minitest::Test
358
358
  )
359
359
 
360
360
  assert_includes output, "Metadata: Meta description exceeds 160 characters (1 warning)\n - /page 184 characters"
361
- assert_includes output, "Metadata: Meta description below 110 characters (1 warning)\n - /page 40 characters"
361
+ assert_includes output, "Metadata: Short meta description (1 warning)\n - /page 40 characters; minimum 110"
362
362
  assert_includes output, "Metadata: Title exceeds 72 characters (1 warning)\n - /page 80 characters"
363
363
  refute_includes output, "meta description:"
364
364
  refute_includes output, "maximum 160"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crawlscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Fidalgo
@@ -206,6 +206,7 @@ files:
206
206
  - lib/crawlscope/crawl.rb
207
207
  - lib/crawlscope/crawler.rb
208
208
  - lib/crawlscope/crawling/fetcher_factory.rb
209
+ - lib/crawlscope/crawling/pagination.rb
209
210
  - lib/crawlscope/crawling/target.rb
210
211
  - lib/crawlscope/crawling/target_resolver.rb
211
212
  - lib/crawlscope/document_text.rb