hdoc-tools 0.28.0 → 0.29.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/hdoc-validate.js +11 -6
  2. package/package.json +1 -1
package/hdoc-validate.js CHANGED
@@ -458,15 +458,14 @@ const e = require("express");
458
458
  if (!valid_url) {
459
459
  // Could be a relative path, check
460
460
  if (links[i].startsWith("/") && !links[i].startsWith("/#")) {
461
- let link_root = links[i].split("/");
462
- if (link_root[0] === "") link_root.shift();
463
- link_root = link_root[0] === "_books" ? link_root[1] : link_root[0];
461
+ let link_segments = links[i].split("/");
462
+ if (link_segments[0] === "") link_segments.shift();
463
+ const link_root = link_segments[0] === "_books" ? link_segments[1] : link_segments[0];
464
464
 
465
465
  // Checking for internal links in other books - can't easily validate those here, returning
466
- if (link_root !== hdocbook_config.docId) {
466
+ if (link_segments.length > 1 && link_root !== hdocbook_config.docId) {
467
467
  continue;
468
468
  }
469
-
470
469
  isRelativePath(source_path, htmlFile, links[i]);
471
470
  } else if (links[i].startsWith("#") || links[i].startsWith("/#")) {
472
471
  //Flat Anchor - validate we have a same-file hit
@@ -543,7 +542,7 @@ const e = require("express");
543
542
  url: links[i],
544
543
  method: 'get',
545
544
  timeout: 10000,
546
- maxRedirects: 0,
545
+ maxRedirects: 5,
547
546
  validateStatus: (status) =>
548
547
  status >= 200 && status < 400,
549
548
  })
@@ -577,6 +576,12 @@ const e = require("express");
577
576
  for (let i = 0; i < links.length; i++) {
578
577
  // Validate that image is a valid URL first
579
578
  if (!hdoc.valid_url(links[i])) {
579
+
580
+ if (!links[i].startsWith("/")) {
581
+ const error_message = processErrorMessage(`Root relative image links should start with a forward-slash: ${links[i]}`, markdown_paths.relativePath, markdown_content, links[i]);
582
+ errors[htmlFile.relativePath].push(error_message);
583
+ }
584
+
580
585
  // Could be a relative path, check image exists
581
586
  doesFileExist(source_path, htmlFile, links[i], markdown_paths.relativePath, markdown_content);
582
587
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.28.0",
3
+ "version": "0.29.1",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {