mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 15:14:20 +01:00
- Add project structure with TypeScript, React, and Vite - Implement nostr authentication using browser extension (NIP-07) - Add NIP-51 compliant bookmark fetching and display - Create minimal UI with login and bookmark components - Integrate applesauce-core and applesauce-react libraries - Add responsive styling with dark/light mode support - Include comprehensive README with setup instructions This is a minimal MVP for a nostr bookmark client that allows users to view their bookmarks according to NIP-51 specification.
41 lines
1.6 KiB
JavaScript
Executable File
41 lines
1.6 KiB
JavaScript
Executable File
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
|