mirror of
https://github.com/lumina-rocks/lumina.git
synced 2026-06-04 01:31:13 +02:00
fix: sanitize relay URLs by removing trailing slashes
This commit is contained in:
@@ -29,9 +29,14 @@ export default function RootLayout({
|
||||
try {
|
||||
const customRelays = JSON.parse(localStorage.getItem("customRelays") || "[]");
|
||||
if (customRelays.length > 0) {
|
||||
// Remove trailing slashes from any relay URLs
|
||||
const sanitizedRelays = customRelays.map((relay: string) =>
|
||||
relay.endsWith('/') ? relay.slice(0, -1) : relay
|
||||
);
|
||||
|
||||
setRelayUrls(prevRelays => {
|
||||
// Combine default relays with custom relays, removing duplicates
|
||||
const allRelays = [...prevRelays, ...customRelays];
|
||||
const allRelays = [...prevRelays, ...sanitizedRelays];
|
||||
return Array.from(new Set(allRelays)); // Remove duplicates
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ export function AddRelaySheet({ onRelayAdded }: AddRelaySheetProps) {
|
||||
if (!formattedUrl.startsWith("wss://")) {
|
||||
formattedUrl = `wss://${formattedUrl}`;
|
||||
}
|
||||
|
||||
// Remove trailing slash if present
|
||||
if (formattedUrl.endsWith('/')) {
|
||||
formattedUrl = formattedUrl.slice(0, -1);
|
||||
}
|
||||
|
||||
// Check if relay already exists in connected relays
|
||||
const existingRelays = connectedRelays?.map(relay => relay.url) || [];
|
||||
|
||||
Reference in New Issue
Block a user