Class: Marlens::GithubToJiraComment::JiraUrl
- Inherits:
-
Object
- Object
- Marlens::GithubToJiraComment::JiraUrl
- Defined in:
- lib/marlens/github_to_jira_comment/jira_url.rb
Defined Under Namespace
Classes: Issue
Class Method Summary collapse
Class Method Details
.parse(url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/marlens/github_to_jira_comment/jira_url.rb', line 10 def self.parse(url) uri = URI.parse(url) match = uri.path.match(%r{\A/browse/([A-Z][A-Z0-9_]*-\d+)\z}) unless uri.is_a?(URI::HTTPS) && uri.host&.end_with?(".atlassian.net") && match raise ArgumentError, "Jira URL must be https://<site>.atlassian.net/browse/<ISSUE-KEY>" end Issue.new(base_url: "#{uri.scheme}://#{uri.host}", issue_key: match[1]) rescue URI::InvalidURIError raise ArgumentError, "Invalid Jira URL" end |