Class: Teems::Services::TeamsUrlParser
- Inherits:
-
Object
- Object
- Teems::Services::TeamsUrlParser
- Defined in:
- lib/teems/services/teams_url_parser.rb
Overview
Parses Microsoft Teams URLs to extract conversation and message identifiers
Defined Under Namespace
Classes: Result
Constant Summary collapse
- TEAMS_HOST =
'teams.microsoft.com'- MESSAGE_PATH_PATTERN =
%r{^/l/message/([^/]+)/(\d+)$}
Class Method Summary collapse
Class Method Details
.match_and_build(uri) ⇒ Object
26 27 28 29 |
# File 'lib/teems/services/teams_url_parser.rb', line 26 def match_and_build(uri) match = uri.path.match(MESSAGE_PATH_PATTERN) match ? build_result(match, uri.query) : nil end |
.parse(url) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/teems/services/teams_url_parser.rb', line 17 def parse(url) uri = URI.parse(url) return nil unless teams_url?(uri) match_and_build(uri) rescue URI::InvalidURIError nil end |
.teams_url?(uri_or_string) ⇒ Boolean
31 32 33 34 35 36 |
# File 'lib/teems/services/teams_url_parser.rb', line 31 def teams_url?(uri_or_string) uri = uri_or_string.is_a?(URI) ? uri_or_string : URI.parse(uri_or_string.to_s) uri.host == TEAMS_HOST rescue URI::InvalidURIError false end |