hdoc-tools 0.14.2 → 0.14.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/hdoc-build.js CHANGED
@@ -669,7 +669,8 @@
669
669
 
670
670
  if (hdocbook_project.redirects && hdocbook_project.redirects instanceof Array) {
671
671
  for (let i = 0; i < hdocbook_project.redirects.length; i++) {
672
- redirects[hdocbook_project.redirects[i].url] = hdocbook_project.redirects[i];
672
+ const redirect_key = hdocbook_project.redirects[i].url.indexOf('/') == 0 ? hdocbook_project.redirects[i].url.substring(1) : hdocbook_project.redirects[i].url;
673
+ redirects[redirect_key] = hdocbook_project.redirects[i];
673
674
  }
674
675
  }
675
676
 
package/hdoc-validate.js CHANGED
@@ -101,7 +101,8 @@
101
101
  // See if there's a redirect in place
102
102
  let redirected = false;
103
103
  let redirect_errored = false;
104
- const redir = await checkRedirect(source_path, key_no_hash);
104
+ const redir = checkRedirect(source_path, key_no_hash);
105
+
105
106
  if (redir.exists && redir.error !== null) {
106
107
  nav_errors.push(redir.error);
107
108
  redirect_errored = true;
@@ -193,7 +194,7 @@
193
194
  return nav_errors;
194
195
  };
195
196
 
196
- const checkRedirect = async function (source_path, nav_path) {
197
+ const checkRedirect = function (source_path, nav_path) {
197
198
  let response = {
198
199
  exists: false,
199
200
  error: null
@@ -220,7 +221,7 @@
220
221
  return response;
221
222
  }
222
223
 
223
- const checkLinks = async function (source_path, htmlFile, links, hdocbook_config) {
224
+ const checkLinks = async function (source_path, htmlFile, links, hdocbook_config, redirects) {
224
225
  for (let i = 0; i < links.length; i++) {
225
226
 
226
227
  // Validate that link is a valid URL first
@@ -376,7 +377,16 @@
376
377
  if (response.is_rel_path) {
377
378
  messages[html_path.relativePath].push(`Relative path exists: ${relative_path}`);
378
379
  } else {
379
- errors[html_path.relativePath].push(`Link path does not exist: ${relative_path}`);
380
+
381
+ // See if there's a redirect in place
382
+ const relpath = relative_path.indexOf('/') == 0 ? relative_path.substring(1) : relative_path;
383
+ const redir = checkRedirect(source_path, relpath);
384
+ if (redir.exists) {
385
+ if (redir.error !== null)
386
+ errors[html_path.relativePath].push(redir.error);
387
+ } else {
388
+ errors[html_path.relativePath].push(`Link path does not exist: ${relative_path}`);
389
+ }
380
390
  }
381
391
  }
382
392
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {