hdoc-tools 0.17.19 → 0.17.20

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/hdoc-validate.js +21 -16
  2. package/package.json +1 -1
package/hdoc-validate.js CHANGED
@@ -268,24 +268,29 @@
268
268
  const checkRedirects = async function (source_path) {
269
269
  let errors = [];
270
270
  for (const key in redirects) {
271
- if (redirects.hasOwnProperty(key) && redirects[key].location) {
272
- let redir_locations = [
273
- path.join(source_path, redirects[key].location + '.md'),
274
- path.join(source_path, redirects[key].location, 'index.md'),
275
- path.join(source_path, redirects[key].location + '.html'),
276
- path.join(source_path, redirects[key].location + '.htm'),
277
- path.join(source_path, redirects[key].location, 'index.html'),
278
- path.join(source_path, redirects[key].location, 'index.htm')
279
- ];
280
- let redir_location_ok = false;
281
- for (let i = 0; i < redir_locations.length; i++) {
282
- if (fs.existsSync(redir_locations[i])) {
283
- redir_location_ok = true;
284
- break;
271
+ if (redirects.hasOwnProperty(key)) {
272
+ if (redirects[key].code !== 301 && redirects[key].code !== 308 && redirects[key].code !== 410 )
273
+ errors.push(`Invalid redirect code: ${redirects[key].code}`);
274
+
275
+ if (redirects[key].location) {
276
+ let redir_locations = [
277
+ path.join(source_path, redirects[key].location + '.md'),
278
+ path.join(source_path, redirects[key].location, 'index.md'),
279
+ path.join(source_path, redirects[key].location + '.html'),
280
+ path.join(source_path, redirects[key].location + '.htm'),
281
+ path.join(source_path, redirects[key].location, 'index.html'),
282
+ path.join(source_path, redirects[key].location, 'index.htm')
283
+ ];
284
+ let redir_location_ok = false;
285
+ for (let i = 0; i < redir_locations.length; i++) {
286
+ if (fs.existsSync(redir_locations[i])) {
287
+ redir_location_ok = true;
288
+ break;
289
+ }
285
290
  }
291
+ if (!redir_location_ok)
292
+ errors.push(`Redirect location does not exist: ${redirects[key].location}`);
286
293
  }
287
- if (!redir_location_ok)
288
- errors.push(`Redirect location does not exist: ${redirects[key].location}`);
289
294
  }
290
295
  }
291
296
  return errors;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.17.19",
3
+ "version": "0.17.20",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {