Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / uri-js / src / schemes / http.ts
1 import { URISchemeHandler, URIComponents, URIOptions } from "../uri";
2
3 const handler:URISchemeHandler = {
4         scheme : "http",
5
6         domainHost : true,
7
8         parse : function (components:URIComponents, options:URIOptions):URIComponents {
9                 //report missing host
10                 if (!components.host) {
11                         components.error = components.error || "HTTP URIs must have a host.";
12                 }
13
14                 return components;
15         },
16
17         serialize : function (components:URIComponents, options:URIOptions):URIComponents {
18                 //normalize the default port
19                 if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") {
20                         components.port = undefined;
21                 }
22                 
23                 //normalize the empty path
24                 if (!components.path) {
25                         components.path = "/";
26                 }
27
28                 //NOTE: We do not parse query strings for HTTP URIs
29                 //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
30                 //and not the HTTP spec.
31
32                 return components;
33         }
34 };
35
36 export default handler;