diff --git a/index.js b/index.js index 6200e07..22e48dd 100644 --- a/index.js +++ b/index.js @@ -96,7 +96,7 @@ export default async function now() { if (latest.image) console.log(`${item.id} Image: ${latest.image}`) if (latest.video) console.log(`${item.id} Video: ${latest.video}`) - // Apply markdown escaping only for markdown links + // apply markdown escaping only for markdown links const displayText = linkFormat === 'html' ? latest.text @@ -109,13 +109,23 @@ export default async function now() { ? htmlServiceLinkRegex(item.id) : markdownServiceLinkRegex(item.id) - newNow = newNow.replace(regex, (match, openTag, closeTag) => { - // Replace href in opening tag + console.log(`\nDEBUG: Testing regex for ${item.id}`) + console.log(`Regex: ${regex}`) + const matched = regex.test(newNow) + console.log(`Regex match found: ${matched}`) + + newNow = newNow.replace(regex, (match, openTag, oldText, closeTag) => { + console.log(`DEBUG: Replacing match for ${item.id}`) + console.log(`Old match: ${match}`) + console.log(`Old text: ${oldText}`) + // replace href in opening tag const updatedOpenTag = openTag.replace( /href=["'][^"']*["']/, `href="${latest.url}"`, ) - return `${updatedOpenTag}${displayText}${closeTag}` + const result = `${updatedOpenTag}${displayText}${closeTag}` + console.log(`New replacement: ${result}`) + return result }) // replace image/video placeholders if available, otherwise remove tags @@ -165,9 +175,15 @@ export default async function now() { }), ) + console.log('\n=== FINAL COMPARISON ===') + console.log(`Original length: ${now.length}`) + console.log(`New length: ${newNow.length}`) + console.log(`Strings are equal: ${now === newNow}`) + if (now === newNow) { console.log('\nNow page has no changes') } else { + console.log('\nChanges detected! Updating Now page...') await setNow(newNow) } } diff --git a/now-page-template.md b/now-page-template.md index eed971c..348c919 100644 --- a/now-page-template.md +++ b/now-page-template.md @@ -2,15 +2,15 @@
This page should update automatically with my latest activity.