You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
954 B

4 years ago
  1. const 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. //normalize the default port
  13. if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") {
  14. components.port = undefined;
  15. }
  16. //normalize the empty path
  17. if (!components.path) {
  18. components.path = "/";
  19. }
  20. //NOTE: We do not parse query strings for HTTP URIs
  21. //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
  22. //and not the HTTP spec.
  23. return components;
  24. }
  25. };
  26. export default handler;
  27. //# sourceMappingURL=http.js.map