Skip to main content

worktree_io/issue/parse/
options.rs

1use anyhow::Result;
2
3use crate::issue::{DeepLinkOptions, IssueRef};
4
5use super::worktree_url;
6
7impl IssueRef {
8    /// Like [`parse`] but also returns any [`DeepLinkOptions`] embedded in a
9    /// `worktree://` URL (e.g. the `editor` query param).
10    ///
11    /// # Errors
12    ///
13    /// Returns an error if `s` cannot be parsed as a valid issue reference.
14    pub fn parse_with_options(s: &str) -> Result<(Self, DeepLinkOptions)> {
15        let s = s.trim();
16        if s.starts_with("worktree://") {
17            return worktree_url::parse_worktree_url(s);
18        }
19        Ok((Self::parse(s)?, DeepLinkOptions::default()))
20    }
21}