Class: Slk::Support::SlackUrlParser
- Inherits:
-
Object
- Object
- Slk::Support::SlackUrlParser
- Defined in:
- lib/slk/support/slack_url_parser.rb
Overview
Parses Slack message URLs into workspace, channel, and timestamp
Defined Under Namespace
Classes: Result
Constant Summary collapse
- URL_PATTERNS =
Patterns for Slack URLs Channel IDs: C=channel, G=group DM, D=direct message
[ # https://workspace.slack.com/archives/C123ABC/p1234567890123456 %r{https?://([^.]+)\.slack\.com/archives/([CDG][A-Z0-9]+)/p(\d+)(?:\?thread_ts=(\d+\.\d+))?}, # https://workspace.slack.com/archives/C123ABC (no message) %r{https?://([^.]+)\.slack\.com/archives/([CDG][A-Z0-9]+)/?$} ].freeze
Instance Method Summary collapse
Instance Method Details
#parse(input) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/slk/support/slack_url_parser.rb', line 33 def parse(input) return nil unless input.to_s.include?('slack.com') URL_PATTERNS.each do |pattern| match = input.match(pattern) return build_result(match) if match end nil end |
#slack_url?(input) ⇒ Boolean
44 45 46 |
# File 'lib/slk/support/slack_url_parser.rb', line 44 def slack_url?(input) input.to_s.include?('slack.com/archives') end |