Skip to content

Commit

Permalink
Merge pull request #1884 from dscho/book-redirects
Browse files Browse the repository at this point in the history
Fix book redirects
  • Loading branch information
ttaylorr authored Sep 26, 2024
2 parents 7f4e3a3 + 8781699 commit 8494c7f
Show file tree
Hide file tree
Showing 33 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions external/book/content/book/az/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/az/v2.html"
aliases:
- "/book/az/v2/index.html"
- "/book/az/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/be/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/be/v2.html"
aliases:
- "/book/be/v2/index.html"
- "/book/be/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/bg/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/bg/v2.html"
aliases:
- "/book/bg/v2/index.html"
- "/book/bg/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/cs/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/cs/v2.html"
aliases:
- "/book/cs/v2/index.html"
- "/book/cs/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/de/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/de/v2.html"
aliases:
- "/book/de/v2/index.html"
- "/book/de/index.html"
---
2 changes: 2 additions & 0 deletions external/book/content/book/en/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
url: "/book/en/v2.html"
aliases:
- "/book/en/v2/index.html"
- "/book/en/index.html"
- "/book/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/es/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/es/v2.html"
aliases:
- "/book/es/v2/index.html"
- "/book/es/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/fa/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/fa/v2.html"
aliases:
- "/book/fa/v2/index.html"
- "/book/fa/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/fr/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/fr/v2.html"
aliases:
- "/book/fr/v2/index.html"
- "/book/fr/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/gr/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/gr/v2.html"
aliases:
- "/book/gr/v2/index.html"
- "/book/gr/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/id/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/id/v2.html"
aliases:
- "/book/id/v2/index.html"
- "/book/id/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/it/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/it/v2.html"
aliases:
- "/book/it/v2/index.html"
- "/book/it/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/ja/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/ja/v2.html"
aliases:
- "/book/ja/v2/index.html"
- "/book/ja/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/ko/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/ko/v2.html"
aliases:
- "/book/ko/v2/index.html"
- "/book/ko/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/mk/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/mk/v2.html"
aliases:
- "/book/mk/v2/index.html"
- "/book/mk/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/ms/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/ms/v2.html"
aliases:
- "/book/ms/v2/index.html"
- "/book/ms/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/nl/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/nl/v2.html"
aliases:
- "/book/nl/v2/index.html"
- "/book/nl/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/pl/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/pl/v2.html"
aliases:
- "/book/pl/v2/index.html"
- "/book/pl/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/pt-br/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/pt-br/v2.html"
aliases:
- "/book/pt-br/v2/index.html"
- "/book/pt-br/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/pt-pt/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/pt-pt/v2.html"
aliases:
- "/book/pt-pt/v2/index.html"
- "/book/pt-pt/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/ru/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/ru/v2.html"
aliases:
- "/book/ru/v2/index.html"
- "/book/ru/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/sl/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/sl/v2.html"
aliases:
- "/book/sl/v2/index.html"
- "/book/sl/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/sr/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/sr/v2.html"
aliases:
- "/book/sr/v2/index.html"
- "/book/sr/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/sv/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/sv/v2.html"
aliases:
- "/book/sv/v2/index.html"
- "/book/sv/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/tl/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/tl/v2.html"
aliases:
- "/book/tl/v2/index.html"
- "/book/tl/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/tr/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/tr/v2.html"
aliases:
- "/book/tr/v2/index.html"
- "/book/tr/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/uk/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/uk/v2.html"
aliases:
- "/book/uk/v2/index.html"
- "/book/uk/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/uz/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/uz/v2.html"
aliases:
- "/book/uz/v2/index.html"
- "/book/uz/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/zh-tw/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/zh-tw/v2.html"
aliases:
- "/book/zh-tw/v2/index.html"
- "/book/zh-tw/index.html"
---
1 change: 1 addition & 0 deletions external/book/content/book/zh/v2/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
url: "/book/zh/v2.html"
aliases:
- "/book/zh/v2/index.html"
- "/book/zh/index.html"
---
6 changes: 5 additions & 1 deletion script/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ def save
front_matter = self.front_matter
front_matter["page_title"] = "Git - Book"
front_matter["url"] = "/book/#{@language_code}/v#{@edition}.html"
front_matter["aliases"] = [ "/book/#{@language_code}/v#{@edition}/index.html" ]
front_matter["aliases"] = [
"/book/#{@language_code}/v#{@edition}/index.html",
"/book/#{@language_code}/index.html"
]
front_matter["aliases"].push("/book/index.html") if @language_code == "en"
front_matter["book"]["front_page"] = true
front_matter["book"]["repository_url"] = "https://github.com/#{@@all_books[@language_code]}"
front_matter["book"]["sha"] = self.sha
Expand Down
9 changes: 8 additions & 1 deletion script/serve-public.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ const mimeTypes = {

const handler = (request, response) => {
const pathname = decodeURIComponent(url.parse(request.url).pathname);
let filename = path.join(basePath, pathname === "/" ? "index.html" : pathname);
let filename = path.join(
basePath,
pathname === "/"
? "index.html"
: pathname.endsWith("/")
? `${pathname}index.html`
: pathname
);

let stats = fs.statSync(filename, { throwIfNoEntry: false });
if (!stats?.isFile() && !filename.match(/\.[A-Za-z0-9]{1,11}$/)) {
Expand Down
4 changes: 4 additions & 0 deletions tests/git-scm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ test('manual pages', async ({ page }) => {
})

test('book', async ({ page }) => {
await page.goto(`${url}book/`)
await expect(page).toHaveURL(`${url}book/en/v2`)

await page.goto(`${url}book`)
await expect(page).toHaveURL(`${url}book/en/v2`)

// Navigate to the first section
await page.getByRole('link', { name: 'Getting Started' }).click()
Expand Down

0 comments on commit 8494c7f

Please sign in to comment.