starlight-links-validator 0.13.2 → 0.13.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.
Files changed (2) hide show
  1. package/libs/validation.ts +10 -8
  2. package/package.json +1 -1
@@ -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.3",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to validate internal links.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",