mirror of
https://github.com/aljazceru/awesome-nostr.git
synced 2025-02-22 14:48:59 +00:00
Merge pull request #527 from Yeghro/more-fineTuning
Some more fine tuning
This commit is contained in:
commit
01064901c4
25
script.js
25
script.js
@ -597,26 +597,33 @@ function parseResources(content) {
|
|||||||
|
|
||||||
// Function to parse a single resource line
|
// Function to parse a single resource line
|
||||||
function parseResourceLine(line) {
|
function parseResourceLine(line) {
|
||||||
// Same regex patterns as before
|
// Modified regex patterns to be more lenient
|
||||||
const nameRegex = /\[(.*?)\]/;
|
const nameRegex = /\[(.*?)\]/;
|
||||||
const linkRegex = /\((.*?)\)/;
|
const linkRegex = /\((.*?)\)/;
|
||||||
const starsRegex = /!\[stars\].*?stars\/(.*?)\/.*?style=social/;
|
const starsRegex = /!\[stars\].*?stars\/(.*?)\/.*?style=social/;
|
||||||
const descriptionRegex = /style=social\) - (.*?)(?=(?:\[|\n|$))|(?:\) - )(.*?)(?=(?:\[|\n|$))/;
|
|
||||||
|
// Modified description regex to be optional
|
||||||
|
const descriptionRegex = /(?:\) - )(.*?)(?=(?:\[|\n|$))|(?:style=social\) - )(.*?)(?=(?:\[|\n|$))/;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const name = nameRegex.exec(line)?.[1];
|
const nameMatch = nameRegex.exec(line);
|
||||||
const link = linkRegex.exec(line)?.[1];
|
const linkMatch = linkRegex.exec(line);
|
||||||
const stars = starsRegex.exec(line)?.[1];
|
|
||||||
|
|
||||||
const descMatch = descriptionRegex.exec(line);
|
// Only require name and link to be present
|
||||||
const description = (descMatch?.[1] || descMatch?.[2] || '').trim();
|
if (nameMatch?.[1] && linkMatch?.[1]) {
|
||||||
|
const name = nameMatch[1].trim();
|
||||||
|
const link = linkMatch[1].trim();
|
||||||
|
const stars = starsRegex.exec(line)?.[1];
|
||||||
|
|
||||||
|
// Make description optional
|
||||||
|
const descMatch = descriptionRegex.exec(line);
|
||||||
|
const description = (descMatch?.[1] || descMatch?.[2] || '').trim();
|
||||||
|
|
||||||
if (name && link) {
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
link,
|
link,
|
||||||
stars: stars ? parseInt(stars) : 0,
|
stars: stars ? parseInt(stars) : 0,
|
||||||
description: description || '',
|
description, // This might be an empty string now
|
||||||
raw: line.trim()
|
raw: line.trim()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user