Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config file and logic #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add config file and logic #1

wants to merge 1 commit into from

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.

@@ -8,6 +9,26 @@ export async function check(url = new URL('http://example.com'), referer, seen =
}
seen.add(url.href);
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.

2 participants