@@ -18,15 +18,15 @@ import { getApiRequestHeaders } from "./helpers/index.js";
1818 * for parsing as JSON.
1919 *
2020 * @param {string } url
21- * @param {string } comment - Optional. The app, site, or organisation that is making the request.
21+ * @param {string } userAgentIdentifier - Optional. The app, site, or organisation that is making the request.
2222 * @return {string }
2323 */
24- async function getBody ( url , comment ) {
24+ async function getBody ( url , userAgentIdentifier ) {
2525 return new Promise ( function ( resolve , reject ) {
2626 // Do async job
2727 const req = https . get (
2828 url ,
29- { headers : getApiRequestHeaders ( comment ) } ,
29+ { headers : getApiRequestHeaders ( userAgentIdentifier ) } ,
3030 function ( res ) {
3131 if ( res . statusCode < 200 || res . statusCode >= 300 ) {
3232 return reject (
@@ -52,34 +52,34 @@ async function getBody(url, comment) {
5252 * Check if a domain is hosted by a green web host.
5353 * @param {string|array } domain - The domain to check, or an array of domains to be checked.
5454 * @param {object } db - Optional. A database object to use for lookups.
55- * @param {string } comment - Optional. The app, site, or organisation that is making the request.
55+ * @param {string } userAgentIdentifier - Optional. The app, site, or organisation that is making the request.
5656 * @returns {boolean|array } - A boolean if a string was provided, or an array of booleans if an array of domains was provided.
5757 */
5858
59- function check ( domain , db , comment ) {
59+ function check ( domain , db , userAgentIdentifier ) {
6060 if ( db ) {
6161 return hostingJSON . check ( domain , db ) ;
6262 }
6363
6464 // is it a single domain or an array of them?
6565 if ( typeof domain === "string" ) {
66- return checkAgainstAPI ( domain , comment ) ;
66+ return checkAgainstAPI ( domain , userAgentIdentifier ) ;
6767 } else {
68- return checkDomainsAgainstAPI ( domain , comment ) ;
68+ return checkDomainsAgainstAPI ( domain , userAgentIdentifier ) ;
6969 }
7070}
7171
7272/**
7373 * Check if a domain is hosted by a green web host by querying the Green Web Foundation API.
7474 * @param {string } domain - The domain to check.
75- * @param {string } comment - Optional. The app, site, or organisation that is making the request.
75+ * @param {string } userAgentIdentifier - Optional. The app, site, or organisation that is making the request.
7676 * @returns {boolean } - A boolean indicating whether the domain is hosted by a green web host.
7777 */
78- async function checkAgainstAPI ( domain , comment ) {
78+ async function checkAgainstAPI ( domain , userAgentIdentifier ) {
7979 const res = JSON . parse (
8080 await getBody (
8181 `https://api.thegreenwebfoundation.org/greencheck/${ domain } ` ,
82- comment
82+ userAgentIdentifier
8383 )
8484 ) ;
8585 return res . green ;
@@ -88,17 +88,17 @@ async function checkAgainstAPI(domain, comment) {
8888/**
8989 * Check if an array of domains is hosted by a green web host by querying the Green Web Foundation API.
9090 * @param {array } domains - An array of domains to check.
91- * @param {string } comment - Optional. The app, site, or organisation that is making the request.
91+ * @param {string } userAgentIdentifier - Optional. The app, site, or organisation that is making the request.
9292 * @returns {array } - An array of domains that are hosted by a green web host.
9393 */
94- async function checkDomainsAgainstAPI ( domains , comment ) {
94+ async function checkDomainsAgainstAPI ( domains , userAgentIdentifier ) {
9595 try {
9696 const allGreenCheckResults = JSON . parse (
9797 await getBody (
9898 `https://api.thegreenwebfoundation.org/v2/greencheckmulti/${ JSON . stringify (
9999 domains
100100 ) } `,
101- comment
101+ userAgentIdentifier
102102 )
103103 ) ;
104104 return hostingJSON . greenDomainsFromResults ( allGreenCheckResults ) ;
0 commit comments