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.
- package/hdoc-validate.js +21 -16
- 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)
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
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;
|