Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

help-to-docs.js 514 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  1. const { URL } = require('url')
  2. const patterns = require('../../lib/patterns')
  3. // redirect help.github.com requests to docs.github.com
  4. module.exports = async (req, res, next) => {
  5. if (req.hostname === 'help.github.com') {
  6. // prevent open redirect security vulnerability
  7. const path = req.originalUrl.replace(patterns.multipleSlashes, '/')
  8. const url = new URL(path, 'https://docs.github.com')
  9. const newURL = url.toString()
  10. return res.redirect(301, newURL)
  11. } else {
  12. return next()
  13. }
  14. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...