mirror of
https://github.com/withastro/astro.git
synced 2025-03-24 23:21:57 -05:00
[ci] format
This commit is contained in:
parent
55ddb2ba48
commit
0a407c4326
2 changed files with 7 additions and 6 deletions
|
@ -63,8 +63,9 @@ export class NodeApp extends App {
|
||||||
const protocol =
|
const protocol =
|
||||||
req.headers['x-forwarded-proto'] ??
|
req.headers['x-forwarded-proto'] ??
|
||||||
('encrypted' in req.socket && req.socket.encrypted ? 'https' : 'http');
|
('encrypted' in req.socket && req.socket.encrypted ? 'https' : 'http');
|
||||||
const hostname = req.headers["x-forwarded-host"] ?? req.headers.host ?? req.headers[":authority"];
|
const hostname =
|
||||||
const port = req.headers["x-forwarded-port"];
|
req.headers['x-forwarded-host'] ?? req.headers.host ?? req.headers[':authority'];
|
||||||
|
const port = req.headers['x-forwarded-port'];
|
||||||
const url = `${protocol}://${hostname}${port ? `:${port}` : ''}${req.url}`;
|
const url = `${protocol}://${hostname}${port ? `:${port}` : ''}${req.url}`;
|
||||||
const options: RequestInit = {
|
const options: RequestInit = {
|
||||||
method: req.method || 'GET',
|
method: req.method || 'GET',
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import * as assert from 'node:assert/strict';
|
import * as assert from 'node:assert/strict';
|
||||||
import { before, describe, it } from 'node:test';
|
import { before, describe, it } from 'node:test';
|
||||||
import { TLSSocket } from 'node:tls';
|
import { TLSSocket } from 'node:tls';
|
||||||
|
import * as cheerio from 'cheerio';
|
||||||
import nodejs from '../dist/index.js';
|
import nodejs from '../dist/index.js';
|
||||||
import { createRequestAndResponse, loadFixture } from './test-utils.js';
|
import { createRequestAndResponse, loadFixture } from './test-utils.js';
|
||||||
import * as cheerio from 'cheerio';
|
|
||||||
|
|
||||||
describe('URL', () => {
|
describe('URL', () => {
|
||||||
/** @type {import('./test-utils.js').Fixture} */
|
/** @type {import('./test-utils.js').Fixture} */
|
||||||
|
@ -78,8 +78,8 @@ describe('URL', () => {
|
||||||
let { req, res, text } = createRequestAndResponse({
|
let { req, res, text } = createRequestAndResponse({
|
||||||
headers: {
|
headers: {
|
||||||
'X-Forwarded-Proto': 'https',
|
'X-Forwarded-Proto': 'https',
|
||||||
'X-Forwarded-Host': 'abc.xyz',
|
'X-Forwarded-Host': 'abc.xyz',
|
||||||
'X-Forwarded-Port': '444'
|
'X-Forwarded-Port': '444',
|
||||||
},
|
},
|
||||||
url: '/',
|
url: '/',
|
||||||
});
|
});
|
||||||
|
@ -90,6 +90,6 @@ describe('URL', () => {
|
||||||
const html = await text();
|
const html = await text();
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
assert.equal($('body').text(), "https://abc.xyz:444/");
|
assert.equal($('body').text(), 'https://abc.xyz:444/');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue