fix(docs-infra): do not auto-link http:// to the common/http (#31051)

Previously, our auto-linking feature would match `http` in URLs (such as
`http://...`) to the `common/http` package and automatically create a
link to that, which was undesirable. While it is possible to work around
that via `<code class="no-auto-link">http://...</code>`, most people
didn't even realize the issue.

Since in this case it is possible to reliably know it is a false match,
this commit fixes it by applying a custom auto-link filter that ignores
all docs for `http`, if it comes before `://`.

Fixes #31012

PR Close #31051
This commit is contained in:
George Kalpakas
2019-06-14 14:02:56 +03:00
committed by Kara Erickson
parent 7814ef55c5
commit c6b180380a
5 changed files with 67 additions and 4 deletions

View File

@ -38,7 +38,7 @@ module.exports = function autoLinkCode(getDocFromAlias) {
// Only interested in text nodes that are not inside links
if (ancestors.every(ancestor => !is(ancestor, 'a'))) {
const parent = ancestors[ancestors.length-1];
const parent = ancestors[ancestors.length - 1];
const index = parent.children.indexOf(node);
// Can we convert the whole text node into a doc link?
@ -66,6 +66,7 @@ module.exports = function autoLinkCode(getDocFromAlias) {
});
};
}
function foundValidDoc(docs) {
return docs.length === 1 &&
!docs[0].internal &&