Match prefixes on entities
This commit is contained in:
@@ -187,7 +187,7 @@ export const isTopic = (parsed: Parsed): parsed is ParsedTopic => parsed.type ==
|
|||||||
// Parsers for known formats
|
// Parsers for known formats
|
||||||
|
|
||||||
export const parseAddress = (text: string, context: ParseContext): ParsedAddress | void => {
|
export const parseAddress = (text: string, context: ParseContext): ParsedAddress | void => {
|
||||||
const [naddr] = text.match(/^(web\+)?(nostr:)?\/?\/?naddr1[\d\w]+/i) || []
|
const [naddr] = text.match(/^(web\+)?(nostr:)naddr1[\d\w]+/i) || []
|
||||||
|
|
||||||
if (naddr) {
|
if (naddr) {
|
||||||
try {
|
try {
|
||||||
@@ -201,7 +201,7 @@ export const parseAddress = (text: string, context: ParseContext): ParsedAddress
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const parseCashu = (text: string, context: ParseContext): ParsedCashu | void => {
|
export const parseCashu = (text: string, context: ParseContext): ParsedCashu | void => {
|
||||||
const [value] = text.match(/^(cashu)[-\d\w=]{50,5000}/i) || []
|
const [value] = text.match(/^cashu:cashu[-\d\w=]{50,5000}/i) || []
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
return {type: ParsedType.Cashu, value, raw: value}
|
return {type: ParsedType.Cashu, value, raw: value}
|
||||||
@@ -235,7 +235,7 @@ export const parseEmoji = (text: string, context: ParseContext): ParsedEmoji | v
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const parseEvent = (text: string, context: ParseContext): ParsedEvent | void => {
|
export const parseEvent = (text: string, context: ParseContext): ParsedEvent | void => {
|
||||||
const [entity] = text.match(/^(web\+)?(nostr:)?\/?\/?n(event|ote)1[\d\w]+/i) || []
|
const [entity] = text.match(/^(web\+)?(nostr:)n(event|ote)1[\d\w]+/i) || []
|
||||||
|
|
||||||
if (entity) {
|
if (entity) {
|
||||||
try {
|
try {
|
||||||
@@ -250,7 +250,7 @@ export const parseEvent = (text: string, context: ParseContext): ParsedEvent | v
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const parseInvoice = (text: string, context: ParseContext): ParsedInvoice | void => {
|
export const parseInvoice = (text: string, context: ParseContext): ParsedInvoice | void => {
|
||||||
const [raw, _, value] = text.match(/^(lightning:)?(ln(bc|url)[0-9a-z]{10,})/i) || []
|
const [raw, _, value] = text.match(/^(lightning:)(ln(bc|url)[0-9a-z]{10,})/i) || []
|
||||||
|
|
||||||
if (raw && value) {
|
if (raw && value) {
|
||||||
return {type: ParsedType.Invoice, value, raw}
|
return {type: ParsedType.Invoice, value, raw}
|
||||||
@@ -301,7 +301,7 @@ export const parseNewline = (text: string, context: ParseContext): ParsedNewline
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const parseProfile = (text: string, context: ParseContext): ParsedProfile | void => {
|
export const parseProfile = (text: string, context: ParseContext): ParsedProfile | void => {
|
||||||
const [entity] = text.match(/^@?(web\+)?(nostr:)?\/?\/?n(profile|pub)1[\d\w]+/i) || []
|
const [entity] = text.match(/^@?(web\+)?(nostr:)n(profile|pub)1[\d\w]+/i) || []
|
||||||
|
|
||||||
if (entity) {
|
if (entity) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ export const socketPolicyReopenActive = (socket: Socket) => {
|
|||||||
|
|
||||||
// If the socket closed and we have no error, reopen it but don't flap
|
// If the socket closed and we have no error, reopen it but don't flap
|
||||||
if (newStatus === SocketStatus.Closed && pending.size) {
|
if (newStatus === SocketStatus.Closed && pending.size) {
|
||||||
sleep(Math.max(0, 30_000 - (Date.now() - lastOpen))).then(() => {
|
sleep(Math.max(0, 10_000 - (Date.now() - lastOpen))).then(() => {
|
||||||
for (const message of pending.values()) {
|
for (const message of pending.values()) {
|
||||||
socket.send(message)
|
socket.send(message)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user