Skip to content

Commit

Permalink
hotfix: server redirect of man.dvc.orl/import-url and
Browse files Browse the repository at this point in the history
other misc. noted on existing redirects

Fixes #768
  • Loading branch information
jorgeorpinel committed Nov 3, 2019
1 parent b120423 commit 24f827e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ app.prepare().then(() => {
} else if (req.headers.host === 'man.dvc.org') {
// man.dvc.org/{cmd} -> dvc.org/doc/command-reference/{cmd}
let normalized_pathname =
['/get-url', '/import-url'].indexOf(pathname) > 0
? pathname.replace(/-/i, '/')
['/get-url', '/import-url'].indexOf(pathname) >= 0
? pathname.replace('-', '/')
: pathname
const doc_pathname = '/doc/command-reference' + normalized_pathname
res.writeHead(301, { Location: 'https://dvc.org' + doc_pathname })
Expand All @@ -50,7 +50,7 @@ app.prepare().then(() => {
})
res.end()
} else if (/^\/doc\/commands-reference(\/.*)?/.test(pathname)) {
// TMP: path /doc/commands-reference/* -> /doc/command-reference/*
// path /doc/commands-reference... -> /doc/command-reference...
res.writeHead(301, {
Location: req.url.replace('commands-reference', 'command-reference')
})
Expand All @@ -65,8 +65,8 @@ app.prepare().then(() => {
pathname === '/doc/use-cases/data-and-model-files-versioning' ||
pathname === '/doc/use-cases/data-and-model-files-versioning/'
) {
// path /doc/use-cases/data-and-model-files-versioning ->
// /doc/use-cases/versioning-data-and-model-files
// path /doc/use-cases/data-and-model-files-versioning
// -> /doc/use-cases/versioning-data-and-model-files
res.writeHead(301, {
Location: req.url.replace(
'data-and-model-files-versioning',
Expand All @@ -75,13 +75,13 @@ app.prepare().then(() => {
})
res.end()
} else if (/^\/doc\/tutorial\/(.*)?/.test(pathname)) {
// path /doc/tutorial/* -> /doc/tutorials/deep/*
// path /doc/tutorial/... -> /doc/tutorials/deep/...
res.writeHead(301, {
Location: req.url.replace('/doc/tutorial/', '/doc/tutorials/deep/')
})
res.end()
} else if (/^\/doc.*/i.test(pathname)) {
// path /doc* -> /doc
// path /doc*/... -> /doc/...
let normalized_pathname = pathname.replace(/^\/doc[^?\/]*/i, '/doc')
if (normalized_pathname !== pathname) {
res.writeHead(301, {
Expand All @@ -103,7 +103,7 @@ app.prepare().then(() => {
})
res.end()
} else if (/^\/(help|chat)\/?$/i.test(pathname)) {
// dvc.org/(help|chat) -> Discord Chat
// dvc.org/(help|chat) -> Discord chat
res.writeHead(301, { Location: 'https://discordapp.com/invite/dvwXA2N' })
res.end()
} else {
Expand Down

0 comments on commit 24f827e

Please sign in to comment.