Skip to content

Commit

Permalink
server: fix man.dvc.org/get-url redirect bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeorpinel committed Aug 15, 2019
1 parent 9a35566 commit 7c36dc9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file doesn't go through babel or webpack transformation.
// Make sure the syntax and sources this file requires are compatible with the
// current node version you are running
// current node version you are running.
// See https://github.com/zeit/next.js/issues/1245 for discussions on Universal
// Webpack or universal Babel
// Webpack or universal Babel.

const { createServer } = require('http')
const { parse } = require('url')
const _ = require('force-ssl-heroku')
Expand All @@ -25,7 +26,9 @@ app.prepare().then(() => {

if (req.headers.host === 'man.dvc.org') {
let normalized_pathname =
pathname !== '/import-url' ? pathname.replace(/-/i, '/') : pathname
['/get-url', '/import-url'].indexOf(pathname) > 0
? pathname.replace(/-/i, '/')
: pathname
const doc_pathname = '/doc/commands-reference' + normalized_pathname
res.writeHead(301, { Location: 'https://dvc.org' + doc_pathname })
res.end()
Expand Down

0 comments on commit 7c36dc9

Please sign in to comment.