remark-github treats '.YYYYMMDD' as a commit ID.
trustin opened this issue · comments
Subject of the issue
For example, 2.10.2.20200130
(a version number) is rendered as:
2.10.2.[2020013](https://github.com/remarkjs/remark-github/commit/20200130)
when it's expected to be rendered in verbatim. Also, note the omission of the trailing 0
.
Your environment
- OS: Linux
- Packages:
remark-github
9.0.0 (viagatsby-plugin-mdx
) - Env: node 12.16.2, yarn 1.22.4, gatsby 2.20.29, gatsby-plugin-mdx 1.1.10
Steps to reproduce
Try to render 2.10.2.20200130
in an MDX file.
Expected behaviour
2.10.2.20200130
should be rendered as it is.- The digits without a leading whitespace should not be treated as a commit ID.
Actual behaviour
2.10.2.20200130
is rendered incorrectly:
2.10.2.[2020013](https://github.com/remarkjs/remark-github/commit/20200130)
In case of Github:
- aba315b is treated as a commit ID.
- 2.10.2.aba315b is not treated as a commit ID.
Hi there! 👋
4843501 is valid sha here, starting with lots of non-hex-digits, and indeed, it doesn’t link:
2.10.2.48435012
GitHub performs a check whether a SHA exists, which we can’t do (it would be too expensive):
4843501
48435013
GitHub also doesn’t publish how this works exactly, so we’ll have to reverse engineer that.
Fix would be to tighten this regex:
remark-github/lib/tokenizer/hash.js
Line 10 in 168480a
...not exactly sure how tight to do it though.
As you might noticed, even if 4843501 is a valid SHA, 2.10.2.4843501 is not treated as a SHA.
Yeah I noticed that (“and indeed, it doesn’t link:”)
Do you have any thoughts on how to tighten that regex?
Fixed, released in 9.0.1!
Thank you so much, @wooorm! Sorry that I didn't have a chance to provide a meaningful feed back on your last question. 🙇
Great, and no problem!