Skip to content

Conversation

@ernestd
Copy link
Collaborator

@ernestd ernestd commented Dec 16, 2022

returns yellow status if:

  • status 200 but destination content matches custom string
  • config status doesn't match res status
  • config status is preset to non 200 status

@ernestd ernestd requested a review from styfle December 16, 2022 09:45
@@ -1,5 +1,6 @@
import fetch from 'node-fetch'
import { load } from 'cheerio'
import links from './links.json' assert { type: 'json' }
Copy link
Owner

@styfle styfle Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize this feature is already available

Although it prints a warning every time https://nodejs.org/api/esm.html#json-modules

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just call it config.mjs to avoid the warning. The user can't even configure this as its written.

const res = await fetch(url, { headers: { 'user-agent': 'npm:links-awakening' } }).catch(e => e);
const html = res.ok ? await res.text() : null;

// deal with config cases
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// deal with config cases


// deal with config cases
for (const link of links.config) {
if (url.href.includes(link.url)) { // TODO: this check needs precision in url comparison (www vs no www), etc
Copy link
Owner

@styfle styfle Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very least, we need startsWith. But we probably need something like this new feature in the future: https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants