Improve relay validation and add sort function
This commit is contained in:
@@ -207,8 +207,10 @@ export const uniqBy = <T>(f: (x: T) => any, xs: T[]) => {
|
||||
return r
|
||||
}
|
||||
|
||||
export const sort = <T>(xs: T[]) => [...xs].sort()
|
||||
|
||||
export const sortBy = <T>(f: (x: T) => number, xs: T[]) =>
|
||||
xs.sort((a: T, b: T) => f(a) - f(b))
|
||||
[...xs].sort((a: T, b: T) => f(a) - f(b))
|
||||
|
||||
export const groupBy = <T, K>(f: (x: T) => K, xs: T[]) => {
|
||||
const r = new Map<K, T[]>()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/lib",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.8",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of utilities.",
|
||||
|
||||
@@ -19,6 +19,8 @@ export const isShareableRelayUrl = (url: string) =>
|
||||
!url.match(/\s|%/) &&
|
||||
// Don't match stuff with a port number
|
||||
!url.slice(6).match(/:\d+/) &&
|
||||
// Don't match stuff with a numeric tld
|
||||
!url.slice(6).match(/\.\d+\b/) &&
|
||||
// Don't match raw ip addresses
|
||||
!url.slice(6).match(/\d+\.\d+\.\d+\.\d+/) &&
|
||||
// Skip nostr.wine's virtual relays
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/util",
|
||||
"version": "0.0.10",
|
||||
"version": "0.0.11",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of nostr-related utilities.",
|
||||
|
||||
Reference in New Issue
Block a user