starlight-links-validator 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/libs/remark.ts CHANGED
@@ -6,6 +6,7 @@ import GitHubSlugger, { slug } from 'github-slugger'
6
6
  import type { Nodes } from 'hast'
7
7
  import { fromHtml } from 'hast-util-from-html'
8
8
  import { hasProperty } from 'hast-util-has-property'
9
+ import isAbsoluteUrl from 'is-absolute-url'
9
10
  import type { Root } from 'mdast'
10
11
  import type { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx'
11
12
  import { toString } from 'mdast-util-to-string'
@@ -133,7 +134,7 @@ export function getValidationData() {
133
134
  }
134
135
 
135
136
  function isInternalLink(link: string) {
136
- return nodePath.isAbsolute(link) || link.startsWith('#') || link.startsWith('.')
137
+ return !isAbsoluteUrl(link)
137
138
  }
138
139
 
139
140
  function normalizeFilePath(base: string, filePath?: string) {
@@ -113,7 +113,7 @@ function validateLink(context: ValidationContext) {
113
113
  throw new Error('Failed to validate a link with no path.')
114
114
  }
115
115
 
116
- if (path.startsWith('.')) {
116
+ if (path.startsWith('.') || !link.startsWith('/')) {
117
117
  if (options.errorOnRelativeLinks) {
118
118
  addError(errors, filePath, link, ValidationErrorType.RelativeLink)
119
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-links-validator",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to validate internal links.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",
@@ -13,6 +13,7 @@
13
13
  "github-slugger": "2.0.0",
14
14
  "hast-util-from-html": "2.0.1",
15
15
  "hast-util-has-property": "3.0.0",
16
+ "is-absolute-url": "4.0.1",
16
17
  "kleur": "4.1.5",
17
18
  "mdast-util-to-string": "4.0.0",
18
19
  "unist-util-visit": "5.0.0"