Sha256: b5c2322210ea4826b8e18abba0ac76e0862f9951bcafcc9550242b6a059740b2

Contents?: true

Size: 488 Bytes

Versions: 4

Compression:

Stored size: 488 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Middleware
    class Normalize
      def call(task)
        yield if block_given?

        task.metadata.staged_urls = SortedSet.new(normalized_urls(task).compact)
      end

    private

      def normalized_urls(task)
        task.metadata.staged_urls.map(&method(:normalize))
      end

      def normalize(url)
        NormalizeUrl.process(url)
      rescue NormalizeUrl::InvalidURIError
        nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wayfarer-0.4.3 lib/wayfarer/middleware/normalize.rb
wayfarer-0.4.2 lib/wayfarer/middleware/normalize.rb
wayfarer-0.4.1 lib/wayfarer/middleware/normalize.rb
wayfarer-0.4.0 lib/wayfarer/middleware/normalize.rb