Support Enterprise Managed User in userGroup Regex#46
Support Enterprise Managed User in userGroup Regex#46EvHaus wants to merge 1 commit intoremarkjs:mainfrom
Conversation
| // | ||
| // \* That is: until <https://github.com/remarkjs/remark-github/issues/13>. | ||
| const userGroup = '[\\da-z][-\\da-z]{0,38}' | ||
| const userGroup = '[\\da-z](?:[-_\\da-z]{0,37}[\\da-z-])?' |
There was a problem hiding this comment.
I'll be honest, GPT-5 did most of the work here as my Regex skills aren't good enough to optimize this. Two things needed:
- Allow
_in addition to-anda-z - BUT -- make sure
_is not the last character in the string, otherwise this could break markdown formatting
|
Do you have an exact quote from the website you are basing this on?
Sounds like perhaps something else is needed, allowing one underscore + shortcode and checking length with code, rather than just allowing arbitrary underscores except at the last character? 🤔 |
Yup -- it's that one that you found: "On GitHub.com, GitHub also adds an underscore and your enterprise's shortcode to the end of each username.".
The exact user id I ran into was
Sure. I can revise the Regex to only check for a single instance. |
Initial checklist
Description of changes
A GitHub Enterprise customer discovered a bug in our product today (that uses
remark-github). Their code was crashing with:After a bunch of troubleshooting I discovered it's because their GitHub username has an
_(underscore) in it. Turns out although generally this is not allowed on GitHub, Enterprise Managed Users can have underscores (see official docs).This PR updates the Regex to support this and adds a unit test to catch this edge case.