starlight-links-validator 0.13.2 → 0.13.4

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
@@ -56,7 +56,9 @@ export const remarkStarlightLinksValidator: Plugin<[{ base: string; srcDir: URL
56
56
  break
57
57
  }
58
58
 
59
- fileHeadings.push(slugger.slug(content))
59
+ // Remove the last trailing hyphen from the slug like Astro does if it exists.
60
+ // https://github.com/withastro/astro/blob/74ee2e45ecc9edbe285eadee6d0b94fc47d0d125/packages/integrations/markdoc/src/heading-ids.ts#L21
61
+ fileHeadings.push(slugger.slug(content).replace(/-$/, ''))
60
62
 
61
63
  break
62
64
  }
@@ -19,7 +19,8 @@ export const ValidationErrorType = {
19
19
  InvalidLink: 'invalid link',
20
20
  LocalLink: 'local link',
21
21
  RelativeLink: 'relative link',
22
- TrailingSlash: 'trailing slash',
22
+ TrailingSlashMissing: 'missing trailing slash',
23
+ TrailingSlashForbidden: 'forbidden trailing slash',
23
24
  } as const
24
25
 
25
26
  export function validateLinks(
@@ -168,13 +169,14 @@ function validateLink(context: ValidationContext) {
168
169
  return
169
170
  }
170
171
 
171
- if (
172
- path.length > 0 &&
173
- ((astroConfig.trailingSlash === 'always' && !path.endsWith('/')) ||
174
- (astroConfig.trailingSlash === 'never' && path.endsWith('/')))
175
- ) {
176
- addError(errors, filePath, link, ValidationErrorType.TrailingSlash)
177
- return
172
+ if (path.length > 0) {
173
+ if (astroConfig.trailingSlash === 'always' && !path.endsWith('/')) {
174
+ addError(errors, filePath, link, ValidationErrorType.TrailingSlashMissing)
175
+ return
176
+ } else if (astroConfig.trailingSlash === 'never' && path.endsWith('/')) {
177
+ addError(errors, filePath, link, ValidationErrorType.TrailingSlashForbidden)
178
+ return
179
+ }
178
180
  }
179
181
  }
180
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-links-validator",
3
- "version": "0.13.2",
3
+ "version": "0.13.4",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to validate internal links.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",