Sha256: 54b27c3e4ea9a8944ffce67cd8b3717fdd81b76effb81b558565c1a53fd3f353
Contents?: true
Size: 595 Bytes
Versions: 48
Compression:
Stored size: 595 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.find { |engine| engine === uri } rescue URI::InvalidURIError nil end end end
Version data entries
48 entries across 48 versions & 1 rubygems