10
45
Fork
You've already forked doipjs
28

Create HTML fetcher #170

Merged
Ryuno-Ki merged 3 commits from quokka/doipjs:add-html into dev 2025年07月30日 18:34:31 +02:00
Contributor
Copy link

See #169

See https://codeberg.org/keyoxide/doipjs/issues/169
Ryuno-Ki left a comment
Copy link

I have the gut feeling that we can have XSS enabled here. We likely should add sanitisation into the mix.

I have the gut feeling that we can have XSS enabled here. We likely should add sanitisation into the mix.
package.json Outdated
@ -23,8 +23,10 @@
"@xmpp/debug": "^0.13.0",
"axios": "^1.6.5",
"browser-or-node": "^1.3.0",
"cheerio": "^1.0.0",
Owner
Copy link

We might be able to use smaller libraries. For example htmlparser2 is used by cheerio.

We might be able to use [smaller](https://bundlephobia.com/package/cheerio@1.1.0) libraries. For example htmlparser2 is used by cheerio.
Author
Contributor
Copy link

I haven't looked into these solutions, but do any of them have a way to query the DOM?

I haven't looked into these solutions, but do any of them have a way to query the DOM?
Owner
Copy link

They do. I've studied cheerios source code and it also supports parse5. Combined with its sanctioned tools we can safe a couple of bytes here :)

They do. I've studied cheerios source code and it also supports [parse5](https://bundlephobia.com/package/parse5@7.3.0). Combined with its [sanctioned tools](https://bundlephobia.com/package/@parse5/tools@0.6.0) we can safe a couple of bytes here :)
@ -0,0 +1,74 @@
/*
Copyright 2021 Daniel Levi
Owner
Copy link

Blast from the past 🤪

Blast from the past 🤪
quokka marked this conversation as resolved
@ -0,0 +18,4 @@
* @module fetcher/html
* @example
* import { fetcher } from 'doipjs';
* const data = await fetcher.html.fn({ url: 'https://example.com', query: '#example' });
Owner
Copy link

# is introducing a fragment. Queries use ?.

`#` is introducing a fragment. Queries use `?`.
quokka marked this conversation as resolved
@ -0,0 +37,4 @@
* @function
* @param {object} data - Data used in the request
* @param {string} data.url - The URL to verify
* @param {string} data.query - The DOM query of the claim
Owner
Copy link

Ah, got it. You mean selector instead of query.

Ah, got it. You mean _selector_ instead of _query_.
quokka marked this conversation as resolved
@ -0,0 +40,4 @@
* @param {string} data.query - The DOM query of the claim
* @param {number} [data.fetcherTimeout] - Optional timeout for the fetcher
* @param {import('../types').VerificationConfig} [opts] - Options used to enable the request
* @returns {Promise<object[]>} The fetched HTML element(s) as objects
Owner
Copy link

I prefer Promise<Array<object>> as notation, but this is personal taste.

I prefer `Promise<Array<object>>` as notation, but this is personal taste.
quokka marked this conversation as resolved
Ryuno-Ki left a comment
Copy link

Let's start from here.

Let's start from here.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
bug
Something is not working

Archived

enhancement
New feature

Archived

Contribution welcome
Get started contributing here
Good first issue
Good if you are new to the project or to open source contributions
Impact
External
Affects the people using the project
Impact
Internal
Affects on the people working on the project
Priority
Critical
Work on right now
Priority
High
Work on at earliest convenience
Priority
Low
Work on in spare time
Priority
Medium
Work on regularly
Review
Duplicate
Already exists
Review
Off Topic
Does not fall within the scope of the repo/project
Status
Backlog
Is not being worked on yet
Status
Blocked
Is waiting on something or someone
Status
Completed
Is done
Status
In Progress
Is being worked on
Status
Investigating
Is waiting on research or questions
Status
Needs Decision
Is waiting on a decision by the devs/contributors
Status
Needs Info
Is waiting on additional information before it can be solved
Status
Needs Triage
Is new issue that needs reviewing
Status
Testing
Is being checked and verified
Status
Waiting For Review
Is waiting on reviewers to approve
Status
Won't Fix
Won't be fixed
Type
Bug
Related to something not working as intended
Type
CI
Related to continuous integration
Type
Documentation
Related to documentation
Type
Enhancement
Related to a new feature or an improved one
Type
New Claim
Related to a new identity claim/proof
Type
Security
Related to security
Type
Tests
Related to code tests
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
keyoxide/doipjs!170
Reference in a new issue
keyoxide/doipjs
No description provided.
Delete branch "quokka/doipjs:add-html"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?