+function isSecure(wsComponents) {
+ return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
+}
+//RFC 6455
+var handler$2 = {
+ scheme: "ws",
+ domainHost: true,
+ parse: function parse(components, options) {
+ var wsComponents = components;
+ //indicate if the secure flag is set
+ wsComponents.secure = isSecure(wsComponents);
+ //construct resouce name
+ wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : '');
+ wsComponents.path = undefined;
+ wsComponents.query = undefined;
+ return wsComponents;
+ },
+ serialize: function serialize(wsComponents, options) {
+ //normalize the default port
+ if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
+ wsComponents.port = undefined;
+ }
+ //ensure scheme matches secure flag
+ if (typeof wsComponents.secure === 'boolean') {
+ wsComponents.scheme = wsComponents.secure ? 'wss' : 'ws';
+ wsComponents.secure = undefined;
+ }
+ //reconstruct path from resource name
+ if (wsComponents.resourceName) {
+ var _wsComponents$resourc = wsComponents.resourceName.split('?'),
+ _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2),
+ path = _wsComponents$resourc2[0],
+ query = _wsComponents$resourc2[1];
+
+ wsComponents.path = path && path !== '/' ? path : undefined;
+ wsComponents.query = query;
+ wsComponents.resourceName = undefined;
+ }
+ //forbid fragment component
+ wsComponents.fragment = undefined;
+ return wsComponents;
+ }
+};
+
+var handler$3 = {
+ scheme: "wss",
+ domainHost: handler$2.domainHost,
+ parse: handler$2.parse,
+ serialize: handler$2.serialize
+};
+