From 17c7bdbe68dd0db80e4589b74decaca1b3519452 Mon Sep 17 00:00:00 2001 From: Goldmaster <7105970+Goldmaster@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:26:55 +0000 Subject: [PATCH] Minor updates to support showing case insitive verified domains --- app/services/verify_link_service.rb | 2 +- spec/services/verify_link_service_spec.rb | 66 ++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/app/services/verify_link_service.rb b/app/services/verify_link_service.rb index fc3c4cbc282..406ba033e25 100644 --- a/app/services/verify_link_service.rb +++ b/app/services/verify_link_service.rb @@ -44,6 +44,6 @@ class VerifyLinkService < BaseService res.headers['Location'] end - redirect_to_url == @link_back + redirect_to_url&.downcase == @link_back.downcase end end diff --git a/spec/services/verify_link_service_spec.rb b/spec/services/verify_link_service_spec.rb index 7e2f9607cfa..138f0aacdb7 100644 --- a/spec/services/verify_link_service_spec.rb +++ b/spec/services/verify_link_service_spec.rb @@ -211,4 +211,68 @@ RSpec.describe VerifyLinkService do end end end -end + + context 'when given a local account with an uppercase URL' do + let(:account) { Fabricate(:account, username: 'alice') } + let(:field) { Account::Field.new(account, 'name' => 'Website', 'value' => 'http://EXAMPLE.COM/Path') } + + before do + stub_request(:get, 'http://EXAMPLE.COM/Path').to_return(status: 200, body: html) + subject.call(field) + end + + context 'when a link contains an back' do + let(:html) do + <<~HTML + + + Follow me on Mastodon + + HTML + end + + it 'marks the field as verified' do + expect(field.verified?).to be true + end + end + + context 'when a link contains an uppercase back' do + let(:html) do + <<~HTML + + + Follow me on Mastodon + + HTML + end + + it 'marks the field as verified' do + expect(field.verified?).to be true + end + end + end + + context 'when link goes through a redirect with different case' do + let(:account) { Fabricate(:account, username: 'alice') } + let(:field) { Account::Field.new(account, 'name' => 'Website', 'value' => 'http://example.com') } + + before do + stub_request(:get, 'http://example.com').to_return(status: 200, body: html) + stub_request(:head, 'https://redirect.me/abc').to_return(status: 301, headers: { 'Location' => ActivityPub::TagManager.instance.url_for(account).upcase }) + subject.call(field) + end + + let(:html) do + <<~HTML + +
+ + + HTML + end + + it 'marks the field as verified' do + expect(field.verified?).to be true + end + end +end \ No newline at end of file