diff --git a/lib/index.js b/lib/index.js index d84795f..e646e18 100644 --- a/lib/index.js +++ b/lib/index.js @@ -132,10 +132,11 @@ const denyHash = new Set([ const minShaLength = 7 // Username may only contain alphanumeric characters or single hyphens, and -// cannot begin or end with a hyphen*. +// cannot begin or end with a hyphen*. Enterprise Managed Users can have +// underscores. // // \* That is: until . -const userGroup = '[\\da-z][-\\da-z]{0,38}' +const userGroup = '[\\da-z](?:[-_\\da-z]{0,37}[\\da-z-])?' const projectGroup = '(?:\\.git[\\w-]|\\.(?!git)|[\\w-])+' const repoGroup = '(' + userGroup + ')\\/(' + projectGroup + ')' diff --git a/test/index.js b/test/index.js index ea292fc..44ef98e 100644 --- a/test/index.js +++ b/test/index.js @@ -118,6 +118,26 @@ test('remarkGithub', async function (t) { } }) + await t.test( + 'should not throw w/ `repository` that belongs to an Enterprise Managed User', + async function () { + const file = await remark() + .use(remarkGfm) + .use(remarkGithub, {repository: 'a_zse/b'}) + .process( + new VFile({ + cwd: new URL('.', import.meta.url).pathname, + value: '12345678' + }) + ) + + assert.equal( + String(file), + '[`1234567`](https://github.com/a_zse/b/commit/12345678)\n' + ) + } + ) + await t.test('should support `buildUrl` for mentions', async function () { const file = await remark() .use(remarkGfm)