Normalize relay urls before putting them in the database

This commit is contained in:
Jon Staab
2024-10-03 12:20:34 -07:00
parent 78c8c9e501
commit 63761c91c8
5 changed files with 29 additions and 16 deletions
+2 -6
View File
@@ -53,12 +53,8 @@ export const isShareableRelayUrl = (url: string) =>
!url.slice(6).match(/\/npub/)
)
type NormalizeRelayUrlOpts = {
allowInsecure?: boolean
}
export const normalizeRelayUrl = (url: string, {allowInsecure = false}: NormalizeRelayUrlOpts = {}) => {
const prefix = allowInsecure ? url.match(/^wss?:\/\//)?.[0] || "wss://" : "wss://"
export const normalizeRelayUrl = (url: string) => {
const prefix = url.match(/^wss?:\/\//)?.[0] || "wss://"
// Use our library to normalize
url = normalizeUrl(url, {stripHash: true, stripAuthentication: false})