[openstreetmap/openstreetmap-website] Add social profile links (PR #5439)
Minh Nguyễn
notifications at github.com
Thu May 15 20:09:52 UTC 2025
@1ec5 commented on this pull request.
> +class SocialLink < ApplicationRecord
+ belongs_to :user
+
+ validates :url, :format => { :with => %r{\A(https?://.+|@([a-zA-Z0-9_]+)@([\w\-\.]+))\z}, :message => :http_parse_error }
+
+ URL_PATTERNS = {
+ :bluesky => %r{\Ahttps?://(?:www\.)?bsky\.app/profile/([a-zA-Z0-9\._-]+)},
+ :discord => %r{\Ahttps?://(?:www\.)?discord\.com/users/(\d+)},
+ :facebook => %r{\Ahttps?://(?:www\.)?facebook\.com/([a-zA-Z0-9.]+)},
+ :flickr => %r{\Ahttps?://(?:www\.)?flickr\.com/people/([a-zA-Z0-9 at ._-]+)},
+ :github => %r{\Ahttps?://(?:www\.)?github\.com/([a-zA-Z0-9_-]+)},
+ :gitlab => %r{\Ahttps?://(?:www\.)?gitlab\.com/([a-zA-Z0-9_-]+)},
+ :instagram => %r{\Ahttps?://(?:www\.)?instagram\.com/([a-zA-Z0-9._]+)},
+ :linkedin => %r{\Ahttps?://(?:www\.)?linkedin\.com/in/([a-zA-Z0-9_-]+)},
+ :line => %r{\Ahttps?://(?:www\.)?line\.me/ti/p/([a-zA-Z0-9_-]+)},
+ :mastodon => %r{\Ahttps?://(?:(?:www\.)?(mastodon\.social|en\.osm\.town))/([@a-zA-Z0-9_]+)},
Yes, a leading `@` is required. Technically the `@` can still appear inside the handle in order to load a profile remotely from a different server, for example, https://mapstodon.space/@tomh@en.osm.town. But I think it’s perfectly fine if we don’t handle that case, since the user should provide a direct URL anyways.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5439#discussion_r2091887989
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5439/review/2844861727 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250515/253af3e8/attachment.htm>
More information about the rails-dev
mailing list