Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: refactor man.dvc.org redirect again and add try to force no-cache #772

Merged
merged 5 commits into from
Nov 4, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,27 @@ app.prepare().then(() => {
) {
// Enforce https protocol and remove www from host/
res.writeHead(301, {
Location:
'https://' + req.headers['host'].replace(/^www\./, '') + req.url
Location: 'https://' + req.headers.host.replace(/^www\./, '') + req.url
})
res.end()
} else if (req.headers.host === 'man.dvc.org') {
// 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
Location:
'https://dvc.org/doc/command-reference' +
(['/get-url', '/import-url'].indexOf(pathname) < 0
? pathname.replace('-', '/')
: pathname)
})
res.end()
} else if (req.headers.host === 'man.localhost:3000') {
res.writeHead(301, {
Location:
'http://localhost:3000/doc/command-reference' +
(['/get-url', '/import-url'].indexOf(pathname) < 0
? pathname.replace('-', '/')
: pathname)
})
jorgeorpinel marked this conversation as resolved.
Show resolved Hide resolved
res.end()
} else if (/^(code|data|remote)\.dvc\.org$/.test(req.headers.host)) {
Expand Down