Skip to content

Commit

Permalink
Merge pull request #771 from iterative/jorgeorpinel
Browse files Browse the repository at this point in the history
hotfix: rewrite man.dvc.org redirect logic without ternary op to see if it fixes #768
  • Loading branch information
shcheklein committed Nov 3, 2019
2 parents a07bd0c + 7204e1e commit 1376f2a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ app.prepare().then(() => {
})
res.end()
} 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('-', '/')
: pathname
const doc_pathname = '/doc/command-reference' + normalized_pathname
res.writeHead(301, { Location: 'https://dvc.org' + doc_pathname })
// man.dvc.org/{cmd} -> dvc.org/doc/command-reference/{cmd},
// replace - for / in {cmd} except for /get-url, /import-url
let new_path
if (['/get-url', '/import-url'].indexOf(pathname) < 0) {
new_path = pathname.replace('-', '/')
} else {
new_path = pathname
}
res.writeHead(301, {
Location: 'https://dvc.org/doc/command-reference' + new_path
})
res.end()
} else if (/^(code|data|remote)\.dvc\.org$/.test(req.headers.host)) {
// {code/data/remote}.dvc.org -> corresponding S3 bucket
Expand Down

0 comments on commit 1376f2a

Please sign in to comment.