fix: remove dependency of localhost url testing on EXTERNAL_URL_RE

pull/503/head
Divyansh Singh 4 years ago
parent 708954644d
commit 423d965103

@ -5,7 +5,7 @@
import MarkdownIt from 'markdown-it'
import { MarkdownRenderer } from '../markdown'
import { URL } from 'url'
import { EXTERNAL_URL_RE } from '../../shared'
import { EXTERNAL_URL_RE, LOCALHOST_URL_RE } from '../../shared'
const indexRE = /(^|.*\/)index.md(#?.*)$/i
@ -25,7 +25,7 @@ export const linkPlugin = (
token.attrSet(key, val)
})
// catch localhost links as dead link
if (url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost:')) {
if (LOCALHOST_URL_RE.test(url)) {
pushLink(url)
}
} else if (

@ -4,7 +4,7 @@ import matter from 'gray-matter'
import LRUCache from 'lru-cache'
import { createMarkdownRenderer, MarkdownOptions } from './markdown/markdown'
import { deeplyParseHeader } from './utils/parseHeader'
import { PageData, HeadConfig, EXTERNAL_URL_RE } from './shared'
import { PageData, HeadConfig, LOCALHOST_URL_RE } from './shared'
import { slash } from './utils/slash'
import chalk from 'chalk'
import _debug from 'debug'
@ -104,7 +104,7 @@ export function createMarkdownToVueRenderFn(
if (data.links) {
const dir = path.dirname(file)
for (let url of data.links) {
if (url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost:')) {
if (LOCALHOST_URL_RE.test(url)) {
recordDeadLink(url)
continue
}

@ -10,6 +10,7 @@ export type {
} from '../../types/shared'
export const EXTERNAL_URL_RE = /:\/\/|\.(?!html|md)\w+$/i
export const LOCALHOST_URL_RE = /:\/\/localhost:/
// @ts-ignore
export const inBrowser = typeof window !== 'undefined'

Loading…
Cancel
Save