Skip to content

Commit 306af33

Browse files
Matthieu Ciapparaclaude
andcommitted
feat: support work_items URLs and ignore URL fragments
GitLab uses both /-/issues/ and /-/work_items/ URL patterns for tickets. The URL parser now tries both patterns. Fragments like #note_813866 are also handled (split on # before extracting IID). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 575f5f5 commit 306af33

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Support for `/-/work_items/` URLs (GitLab work items), in addition to `/-/issues/`.
8+
- URL fragments (`#note_...`) are now ignored during parsing.
9+
510
## [0.1.0] - 2026-04-10
611

712
### Added

bin/issue-md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,27 @@ module UrlParser
9696
raise IssueMdError, "Expected an http(s) URL, got: #{url}"
9797
end
9898

99+
ISSUE_PATTERNS = %w[/-/issues/ /-/work_items/].freeze
100+
99101
def self.extract_path_and_iid(uri, url)
100-
path_before, _, issue_segment = uri.path.partition('/-/issues/')
101-
raise IssueMdError, "URL does not look like a GitLab issue: #{url}" if issue_segment.empty?
102+
path_before, issue_segment = try_patterns(uri.path)
103+
raise IssueMdError, "URL does not look like a GitLab issue: #{url}" unless issue_segment
102104

103-
iid = issue_segment.split('/').first.to_i
105+
iid = issue_segment.split(%r{[/#]}).first.to_i
104106
raise IssueMdError, "Could not extract issue IID from: #{url}" if iid.zero?
105107

106108
[path_before.delete_prefix('/'), iid]
107109
end
108110

109-
private_class_method :validate_scheme!, :extract_path_and_iid
111+
def self.try_patterns(path)
112+
ISSUE_PATTERNS.each do |pattern|
113+
before, _, segment = path.partition(pattern)
114+
return [before, segment] unless segment.empty?
115+
end
116+
nil
117+
end
118+
119+
private_class_method :validate_scheme!, :extract_path_and_iid, :try_patterns
110120
end
111121

112122
# ── Image downloading ─────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)