Skip to content

Commit 31a77d7

Browse files
committed
Check that heading redirects exist in the remapping dictionary.
1 parent 947fc48 commit 31a77d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+328
-164
lines changed

bin/redirects/GuidedTour/Compatibility.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/GuidedTour/GuidedTour.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/AccessControl.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/AdvancedOperators.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/AutomaticReferenceCounting.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/BasicOperators.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/ClassesAndStructures.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/Closures.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/CollectionTypes.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

bin/redirects/LanguageGuide/Concurrency.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
const components = path.split("/");
8585
const part = components[components.length - 2];
8686
const chapter = components[components.length - 1];
87-
const redirectPath = chapterRedirects[part + "/" + chapter];
88-
newURL += redirectPath;
87+
const newPath = part + "/" + chapter;
88+
if (newPath in chapterRedirects) {
89+
newURL += chapterRedirects[part + "/" + chapter];
90+
}
8991
} else {
90-
const redirectPath = headingRedirects[hash];
91-
newURL += redirectPath;
92+
if (hash in headingRedirects) {
93+
const redirectPath = headingRedirects[hash];
94+
newURL += redirectPath;
95+
}
9296
}
9397

9498
document.getElementById("redirect").setAttribute("href", newURL);

0 commit comments

Comments
 (0)