From 13a8629de0385de77bc3e261565d0e196ef618d7 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Fri, 22 Mar 2024 09:03:42 +1100 Subject: [PATCH] Parse found links as URIs --- lib/adamantium/link_finder.rb | 2 +- spec/adamantium/unit/link_finder_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/adamantium/link_finder.rb b/lib/adamantium/link_finder.rb index 7b4d496..a2c84a1 100644 --- a/lib/adamantium/link_finder.rb +++ b/lib/adamantium/link_finder.rb @@ -18,7 +18,7 @@ module Adamantium links.reject do |link| link.end_with?(":") || IGNORE_LIST.include?(URI.parse(link).host) - end + end.map{ |uri| URI(uri) } end end end diff --git a/spec/adamantium/unit/link_finder_spec.rb b/spec/adamantium/unit/link_finder_spec.rb index 196466c..e26b419 100644 --- a/spec/adamantium/unit/link_finder_spec.rb +++ b/spec/adamantium/unit/link_finder_spec.rb @@ -6,6 +6,6 @@ RSpec.describe Adamantium::LinkFinder do it "finds allowed links in a string" do text = "Check out some of these cool websites: https://google.com https://example.com or even http://twitter.com and https://bsky.app" - expect(subject.call(text)).to eq ["https://example.com"] + expect(subject.call(text)).to eq [URI("https://example.com")] end end