• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1const handler = {
2    scheme: "http",
3    domainHost: true,
4    parse: function (components, options) {
5        //report missing host
6        if (!components.host) {
7            components.error = components.error || "HTTP URIs must have a host.";
8        }
9        return components;
10    },
11    serialize: function (components, options) {
12        const secure = String(components.scheme).toLowerCase() === "https";
13        //normalize the default port
14        if (components.port === (secure ? 443 : 80) || components.port === "") {
15            components.port = undefined;
16        }
17        //normalize the empty path
18        if (!components.path) {
19            components.path = "/";
20        }
21        //NOTE: We do not parse query strings for HTTP URIs
22        //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
23        //and not the HTTP spec.
24        return components;
25    }
26};
27export default handler;
28//# sourceMappingURL=http.js.map