|
1 | 1 | import { regex } from '../regex.js'; |
| 2 | +import { replace } from '../helpers.js'; |
2 | 3 | import { template } from '../template.js'; |
3 | 4 | import { url } from '../url.js'; |
4 | 5 | export const pullRequestCompact = (text, repo) => { |
5 | | - const replacerFull = (value, item) => value.replace(item[0], template('pull_request', `${item[1]}/${item[2]}`, item[3])); |
6 | | - const replacerShort = (value, item) => value.replace(item[0], template('pull_request', repo, item[1])); |
| 6 | + const replacerFull = (value, item) => replace(value, item, template('pull_request', `${item[1]}/${item[2]}`, item[3])); |
| 7 | + const replacerShort = (value, item) => replace(value, item, template('pull_request', repo, item[1])); |
7 | 8 | text = regex(text, /\[[\s`#@]*\d+]\(https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/pull\/(\d+)\)/g, replacerFull); |
8 | 9 | text = regex(text, /https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/pull\/(\d+)/g, replacerFull); |
9 | 10 | text = regex(text, /#(\d+)/g, replacerShort); |
10 | 11 | return text; |
11 | 12 | }; |
12 | 13 | export const pullRequestExpand = (text, repo) => { |
13 | 14 | const replacer = (value, item) => value.replace(item[0], url(repo, `${item[1]}#${item[2]}`, `${item[1]}/pull/${item[2]}`)); |
14 | | - text = regex(text, /::pull_request::([\w\d\-_\/]+)::([\w\d\-_]+)::/g, replacer); |
| 15 | + text = regex(text, /::pull_request::([\d\w.\-_\/]+)::([\d\w.\-_\/]+)::/g, replacer); |
15 | 16 | return text; |
16 | 17 | }; |
0 commit comments