@captive/plop-config
Version:
15 lines (14 loc) • 374 B
JavaScript
function undefinedWhenEmpty(value) {
return value == null || value === '' ? undefined : value;
}
const jiraMatcher = /[A-Z]{2,255}-\d+/;
export function extractIssueId(issueURL) {
try {
const url = new URL(issueURL);
// JIRA
return undefinedWhenEmpty(url.pathname.match(jiraMatcher)?.[0]);
}
catch {
return undefined;
}
}