Skip to main content

parse_pr_url

Function parse_pr_url 

Source
pub fn parse_pr_url(url: &str) -> Option<PrUrl>
Expand description

Parse a GitHub PR URL into its components.

Accepts URLs like https://github.com/owner/repo/pull/42 or github.com/owner/repo/pull/42 (without protocol prefix). Returns None if the URL doesn’t match the expected format.

§Examples

use toolpath_github::parse_pr_url;

let pr = parse_pr_url("https://github.com/empathic/toolpath/pull/6").unwrap();
assert_eq!(pr.owner, "empathic");
assert_eq!(pr.repo, "toolpath");
assert_eq!(pr.number, 6);

// Works without protocol prefix too
let pr = parse_pr_url("github.com/empathic/toolpath/pull/6").unwrap();
assert_eq!(pr.number, 6);

assert!(parse_pr_url("not a url").is_none());