From 2bf61aeaa1860742f2a357c5bf6211dd50a4e930 Mon Sep 17 00:00:00 2001 From: Yuri Sidorov <403994+newstler@users.noreply.github.com> Date: Wed, 11 Feb 2026 00:36:27 +0100 Subject: [PATCH] fix(users): prepend https:// to external links missing protocol Website and LinkedIn URLs without a protocol (e.g. "example.com") were rendered as relative paths, linking to rubycommunity.org/example.com instead of the external site. Co-Authored-By: Claude Opus 4.6 --- app/models/user.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4bde2f4..44e7a41 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -141,9 +141,9 @@ def github_ruby_repositories_url def social_links links = {} - links[:website] = website if website.present? + links[:website] = ensure_protocol(website) if website.present? links[:twitter] = "https://twitter.com/#{twitter}" if twitter.present? - links[:linkedin] = linkedin if linkedin.present? + links[:linkedin] = ensure_protocol(linkedin) if linkedin.present? links[:github] = github_profile_url links end @@ -245,6 +245,10 @@ def self.linkify_bio(text) private + def ensure_protocol(url) + url.match?(%r{\A https?:// }x) ? url : "https://#{url}" + end + def precompute_bio_html self.bio_html = self.class.linkify_bio(bio) end