docs: fixes following QA testing (#9690)

This commit is contained in:
Shahed Nasser
2024-10-22 18:20:21 +03:00
committed by GitHub
parent b2122c4073
commit 731309e87a
40 changed files with 70 additions and 66 deletions
@@ -15,7 +15,7 @@ import {
} from "../utils/expression-is-utils.js"
import { ComponentLinkFixerOptions } from "../types/index.js"
const MD_LINK_REGEX = /\[(.*?)\]\((?<link>.*?)\)/gm
const MD_LINK_REGEX = /\[(.*?)\]\((?<link>(![a-z]+!|\.).*?)\)/gm
const VALUE_LINK_REGEX = /^(![a-z]+!|\.)/gm
function matchMdLinks(
@@ -23,8 +23,10 @@ function matchMdLinks(
linkOptions: Omit<FixLinkOptions, "linkedPath">
) {
let linkMatches
// reset regex
MD_LINK_REGEX.lastIndex = 0
while ((linkMatches = MD_LINK_REGEX.exec(str)) !== null) {
if (!linkMatches.groups?.link || linkMatches.groups?.link.startsWith("http")) {
if (!linkMatches.groups?.link) {
return
}
@@ -34,6 +36,8 @@ function matchMdLinks(
})
str = str.replace(linkMatches.groups.link, newUrl)
// reset regex
MD_LINK_REGEX.lastIndex = 0
}
return str
@@ -43,7 +47,9 @@ function matchValueLink(
str: string,
linkOptions: Omit<FixLinkOptions, "linkedPath">
) {
if (!VALUE_LINK_REGEX.exec(str) || str.startsWith("http")) {
// reset index
VALUE_LINK_REGEX.lastIndex = 0
if (!VALUE_LINK_REGEX.exec(str)) {
return str
}