replace queue with worker
This commit is contained in:
@@ -17,7 +17,13 @@ export const isShareableRelayUrl = (url: string) =>
|
||||
!url.slice(6).match(/\/npub/)
|
||||
)
|
||||
|
||||
export const normalizeRelayUrl = (url: string) => {
|
||||
type NormalizeRelayUrlOpts = {
|
||||
allowInsecure?: boolean
|
||||
}
|
||||
|
||||
export const normalizeRelayUrl = (url: string, {allowInsecure = false}: NormalizeRelayUrlOpts = {}) => {
|
||||
const prefix = allowInsecure ? url.match(/^wss?:\/\//)?.[0] || "wss://" : "wss://"
|
||||
|
||||
// Use our library to normalize
|
||||
url = normalizeUrl(url, {stripHash: true, stripAuthentication: false})
|
||||
|
||||
@@ -29,5 +35,5 @@ export const normalizeRelayUrl = (url: string) => {
|
||||
url += "/"
|
||||
}
|
||||
|
||||
return "wss://" + url
|
||||
return prefix + url
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
|
||||
entries = () => this.mapTo(t => t.entry())
|
||||
|
||||
relays = () => this.flatMap((t: Tag) => t.valueOf().filter(isShareableRelayUrl).map(normalizeRelayUrl)).uniq()
|
||||
relays = () => this.flatMap((t: Tag) => t.valueOf().filter(isShareableRelayUrl).map(url => normalizeRelayUrl(url))).uniq()
|
||||
|
||||
topics = () => this.whereKey("t").values().map((t: string) => t.replace(/^#/, ""))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user