Sha256: 59672575a7cad95baebf63ed2c1ca7a02a25693e42d3815f48c2ef357c10861f
Contents?: true
Size: 662 Bytes
Versions: 1
Compression:
Stored size: 662 Bytes
Contents
# frozen_string_literal: true module Onebox class Matcher def initialize(link) @url = link end def ordered_engines @ordered_engines ||= Engine.engines.sort_by do |e| e.respond_to?(:priority) ? e.priority : 100 end end def oneboxed uri = URI(@url) return unless uri.port.nil? || Onebox.options.allowed_ports.include?(uri.port) return unless uri.scheme.nil? || Onebox.options.allowed_schemes.include?(uri.scheme) ordered_engines .select { |engine| engine === uri } .sort_by { |engine| engine.to_s } .last rescue URI::InvalidURIError nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
onebox-2.0.0 | lib/onebox/matcher.rb |