mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Correctly parse URL domain
This commit is contained in:
parent
4df26454d4
commit
5fa068687b
@ -1,5 +1,4 @@
|
|||||||
import type { TLSSocket } from 'tls';
|
import type { TLSSocket } from 'tls';
|
||||||
import { format } from 'url';
|
|
||||||
import type { HttpRequest } from '../../server/HttpRequest';
|
import type { HttpRequest } from '../../server/HttpRequest';
|
||||||
import { toCanonicalUriPath } from '../../util/Util';
|
import { toCanonicalUriPath } from '../../util/Util';
|
||||||
import type { ResourceIdentifier } from '../representation/ResourceIdentifier';
|
import type { ResourceIdentifier } from '../representation/ResourceIdentifier';
|
||||||
@ -23,11 +22,11 @@ export class BasicTargetExtractor extends TargetExtractor {
|
|||||||
throw new Error('Missing host.');
|
throw new Error('Missing host.');
|
||||||
}
|
}
|
||||||
const isHttps = input.connection && (input.connection as TLSSocket).encrypted;
|
const isHttps = input.connection && (input.connection as TLSSocket).encrypted;
|
||||||
const path = format({
|
|
||||||
protocol: `http${isHttps ? 's' : ''}`,
|
// URL object applies punycode encoding to domain
|
||||||
host: toCanonicalUriPath(input.headers.host),
|
const base = `http${isHttps ? 's' : ''}://${input.headers.host}`;
|
||||||
pathname: toCanonicalUriPath(input.url),
|
const url = toCanonicalUriPath(input.url);
|
||||||
});
|
const path = new URL(url, base).href;
|
||||||
|
|
||||||
return { path };
|
return { path };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user