Permalink
Cannot retrieve contributors at this time
executable file
41 lines (41 sloc)
1.62 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/uri-js/dist/esnext/schemes/ws.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |