Skip to content

Commit 9ff03f1

Browse files
newstlerclaude
andauthored
fix(users): prepend https:// to external links missing protocol (#137)
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 <noreply@anthropic.com>
1 parent 8b31b58 commit 9ff03f1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

app/models/user.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def github_ruby_repositories_url
141141

142142
def social_links
143143
links = {}
144-
links[:website] = website if website.present?
144+
links[:website] = ensure_protocol(website) if website.present?
145145
links[:twitter] = "https://twitter.com/#{twitter}" if twitter.present?
146-
links[:linkedin] = linkedin if linkedin.present?
146+
links[:linkedin] = ensure_protocol(linkedin) if linkedin.present?
147147
links[:github] = github_profile_url
148148
links
149149
end
@@ -245,6 +245,10 @@ def self.linkify_bio(text)
245245

246246
private
247247

248+
def ensure_protocol(url)
249+
url.match?(%r{\A https?:// }x) ? url : "https://#{url}"
250+
end
251+
248252
def precompute_bio_html
249253
self.bio_html = self.class.linkify_bio(bio)
250254
end

0 commit comments

Comments
 (0)