https://github.com/qubyte/rel-payment
Discover a rel="payment" donations URL given a URL for the containing page.
https://github.com/qubyte/rel-payment
hacktoberfest
Last synced: about 2 months ago
JSON representation
Discover a rel="payment" donations URL given a URL for the containing page.
- Host: GitHub
- URL: https://github.com/qubyte/rel-payment
- Owner: qubyte
- License: mit
- Created: 2018-02-09T17:42:14.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-31T22:12:27.000Z (7 months ago)
- Last Synced: 2025-03-14T21:04:30.242Z (2 months ago)
- Topics: hacktoberfest
- Language: JavaScript
- Homepage:
- Size: 455 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
README
# rel-payment
Discover [rel="payment"](http://microformats.org/wiki/rel-payment) donation
URIs given a URL for a page which may contain them.## Usage
```javascript
import relPayment from 'rel-payment';// The url parameter may also be a WHATWG URL object.
relPayment('https://qubyte.codes').then(
paymentUris => console.log(paymentUris),
err => console.error(err)
);
```where `paymentUris` looks like:
```javascript
{
fromLinkHeaders: [], // Array of objects distilled from link headers.
fromAnchors: [], // Array of objects distilled from anchors tags.
fromLinks: [] // Array of objects distilled from link tags.
}
```and where each object looks like:
```javascript
{
url: new URL('https://example.com/payment'), // Absolute WHATWG URL object for payments.
title: 'Some info about the payment.'
}
```The title field is populated by the title attribute of the tag.
## HTTP
Be default HTTP pages are not searched for payment links, since it's trivial to
rewrite pages and add link headers. However, if you want to enable this
behaviour you may pass `{ allowHttp: true }` as the second argument to
`relPayment`.## HTTPS
Pages with valid certificates will be searched as expected. Pages without a
valid certificate will cause the call to `relPayment` to throw an error.