Sha256: 00bdd2f3bfdb71165fe98951635769542f2a441ad8a688c7b106721dab75c529

Contents?: true

Size: 1.62 KB

Versions: 52

Compression:

Stored size: 1.62 KB

Contents

function isSecure(wsComponents) {
    return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
}
//RFC 6455
const handler = {
    scheme: "ws",
    domainHost: true,
    parse: function (components, options) {
        const 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 (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) {
            const [path, query] = wsComponents.resourceName.split('?');
            wsComponents.path = (path && path !== '/' ? path : undefined);
            wsComponents.query = query;
            wsComponents.resourceName = undefined;
        }
        //forbid fragment component
        wsComponents.fragment = undefined;
        return wsComponents;
    }
};
export default handler;
//# sourceMappingURL=ws.js.map

Version data entries

52 entries across 51 versions & 7 rubygems

Version Path
trusty-cms-6.3.1 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.51 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.50 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.49 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.48 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.47 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.46 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.45 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.44 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.43 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.42 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.41 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.40 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.39 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.38 node_modules/uri-js/dist/esnext/schemes/ws.js
optimacms-0.1.61 spec/dummy/node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.32 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.31 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.30 node_modules/uri-js/dist/esnext/schemes/ws.js
immosquare-cleaner-0.1.29 node_modules/uri-js/dist/esnext/schemes/ws.js