summaryrefslogtreecommitdiffstats
path: root/test/redirect-relative.js
blob: ca9c5411ba4128a54a7a4e2fdbfa75edeee1d0e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict'

const t = require('tap')
const { request } = require('..')
const {
  startRedirectingWithRelativePath
} = require('./utils/redirecting-servers')

t.test('should redirect to relative URL according to RFC 7231', async t => {
  t.plan(2)

  const server = await startRedirectingWithRelativePath(t)

  const { statusCode, body } = await request(`http://${server}`, {
    maxRedirections: 3
  })

  const finalPath = await body.text()

  t.equal(statusCode, 200)
  t.equal(finalPath, '/absolute/b')
})