diff --git a/api/check-hsts.js b/api/check-hsts.js index 901b7c0..71382cb 100644 --- a/api/check-hsts.js +++ b/api/check-hsts.js @@ -1,7 +1,7 @@ const https = require('https'); exports.handler = async function(event, context) { - const siteURL = event.queryStringParameters.url; + const siteURL = (event.queryStringParameters || event.query).url; const errorResponse = (message, statusCode = 500) => { return { diff --git a/api/check-ports.js b/api/check-ports.js index 4e94c77..00cb266 100644 --- a/api/check-ports.js +++ b/api/check-ports.js @@ -34,7 +34,7 @@ async function checkPort(port, domain) { } exports.handler = async (event, context) => { - const domain = event.queryStringParameters.url; + const domain = (event.queryStringParameters || event.query).url; if (!domain) { return errorResponse('Missing domain parameter.'); diff --git a/api/dns-sec.js b/api/dns-sec.js index a8ff986..c4cf3f3 100644 --- a/api/dns-sec.js +++ b/api/dns-sec.js @@ -1,7 +1,7 @@ const https = require('https'); exports.handler = async function(event, context) { - let { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; if (!url) { return errorResponse('URL query parameter is required.'); diff --git a/api/dns-server.js b/api/dns-server.js index 084f104..3bcbe3b 100644 --- a/api/dns-server.js +++ b/api/dns-server.js @@ -4,7 +4,8 @@ const dnsPromises = dns.promises; const axios = require('axios'); exports.handler = async (event) => { - const domain = event.queryStringParameters.url.replace(/^(?:https?:\/\/)?/i, ""); + const url = (event.queryStringParameters || event.query).url; + const domain = url.replace(/^(?:https?:\/\/)?/i, ""); try { const addresses = await dnsPromises.resolve4(domain); const results = await Promise.all(addresses.map(async (address) => { diff --git a/api/find-url-ip.js b/api/find-url-ip.js index 7172b6a..30355c9 100644 --- a/api/find-url-ip.js +++ b/api/find-url-ip.js @@ -2,7 +2,7 @@ const dns = require('dns'); /* Lambda function to fetch the IP address of a given URL */ exports.handler = function (event, context, callback) { - const addressParam = event.queryStringParameters.url; + const addressParam = (event.queryStringParameters || event.query).url; if (!addressParam) { callback(null, errorResponse('Address parameter is missing.')); diff --git a/api/follow-redirects.js b/api/follow-redirects.js index 7810cd1..42b56db 100644 --- a/api/follow-redirects.js +++ b/api/follow-redirects.js @@ -1,5 +1,5 @@ exports.handler = async (event) => { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; const redirects = [url]; try { diff --git a/api/get-carbon.js b/api/get-carbon.js index c11605b..d975753 100644 --- a/api/get-carbon.js +++ b/api/get-carbon.js @@ -1,7 +1,7 @@ const https = require('https'); exports.handler = async (event, context) => { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; if (!url) { return { diff --git a/api/get-cookies.js b/api/get-cookies.js index 2b17dbe..e2c05f2 100644 --- a/api/get-cookies.js +++ b/api/get-cookies.js @@ -1,7 +1,7 @@ const axios = require('axios'); exports.handler = async function(event, context) { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; if (!url) { return { diff --git a/api/get-dns.js b/api/get-dns.js index 6f80ae9..1be91a2 100644 --- a/api/get-dns.js +++ b/api/get-dns.js @@ -2,7 +2,7 @@ const dns = require('dns'); const util = require('util'); exports.handler = async function(event, context) { - let hostname = event.queryStringParameters.url; + let hostname = (event.queryStringParameters || event.query).url; // Handle URLs by extracting hostname if (hostname.startsWith('http://') || hostname.startsWith('https://')) { diff --git a/api/get-headers.js b/api/get-headers.js index 4006d55..00cf755 100644 --- a/api/get-headers.js +++ b/api/get-headers.js @@ -1,7 +1,7 @@ const axios = require('axios'); exports.handler = async function(event, context) { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; if (!url) { return { diff --git a/api/get-txt.js b/api/get-txt.js index 08eebc2..cf3883b 100644 --- a/api/get-txt.js +++ b/api/get-txt.js @@ -1,7 +1,15 @@ const dns = require('dns').promises; exports.handler = async (event) => { - const url = new URL(event.queryStringParameters.url); + let url = (event.queryStringParameters || event.query).url; + try { + url = new URL(url); + } catch (error) { + return { + statusCode: 400, + body: JSON.stringify({ error: `Invalid URL ${error}` }), + }; + } try { const txtRecords = await dns.resolveTxt(url.hostname); diff --git a/api/lighthouse-report.js b/api/lighthouse-report.js index 7123cca..ab76aff 100644 --- a/api/lighthouse-report.js +++ b/api/lighthouse-report.js @@ -1,7 +1,7 @@ const axios = require('axios'); exports.handler = function(event, context, callback) { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; if (!url) { callback(null, { diff --git a/api/read-robots-txt.js b/api/read-robots-txt.js index 05a084f..50b7449 100644 --- a/api/read-robots-txt.js +++ b/api/read-robots-txt.js @@ -1,7 +1,7 @@ const axios = require('axios'); exports.handler = async function(event, context) { - const siteURL = event.queryStringParameters.url; + const siteURL = (event.queryStringParameters || event.query).url; if (!siteURL) { return { diff --git a/api/screenshot.js b/api/screenshot.js index a581a70..75f1741 100644 --- a/api/screenshot.js +++ b/api/screenshot.js @@ -3,7 +3,7 @@ const chromium = require('chrome-aws-lambda'); exports.handler = async (event, context, callback) => { let browser = null; - let targetUrl = event.queryStringParameters.url; + let targetUrl = (event.queryStringParameters || event.query).url; if (!targetUrl) { callback(null, { diff --git a/api/security-txt.js b/api/security-txt.js index dd6e68b..78ded4c 100644 --- a/api/security-txt.js +++ b/api/security-txt.js @@ -38,7 +38,7 @@ const isPgpSigned = (result) => { }; exports.handler = async (event, context) => { - const urlParam = event.queryStringParameters.url; + const urlParam = (event.queryStringParameters || event.query).url; if (!urlParam) { return { statusCode: 400, diff --git a/api/server-status.js b/api/server-status.js index 6d0dbbf..242df31 100644 --- a/api/server-status.js +++ b/api/server-status.js @@ -2,7 +2,7 @@ const https = require('https'); const { performance, PerformanceObserver } = require('perf_hooks'); exports.handler = async function(event, context) { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; if (!url) { return { diff --git a/api/site-features.js b/api/site-features.js index f38bb3a..d9b6486 100644 --- a/api/site-features.js +++ b/api/site-features.js @@ -1,7 +1,7 @@ const https = require('https'); exports.handler = async function (event, context) { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; const apiKey = process.env.BUILT_WITH_API_KEY; const errorResponse = (message, statusCode = 500) => { diff --git a/api/sitemap.js b/api/sitemap.js index 8b57f01..149835f 100644 --- a/api/sitemap.js +++ b/api/sitemap.js @@ -2,8 +2,9 @@ const axios = require('axios'); const xml2js = require('xml2js'); exports.handler = async (event) => { - const baseUrl = event.queryStringParameters.url.replace(/^(?:https?:\/\/)?/i, ""); - const url = baseUrl.startsWith('http') ? baseUrl : `http://${baseUrl}`; + const url = (event.queryStringParameters || event.query).url; + // const baseUrl = event.queryStringParameters.url.replace(/^(?:https?:\/\/)?/i, ""); + // const url = baseUrl.startsWith('http') ? baseUrl : `http://${baseUrl}`; let sitemapUrl; try { diff --git a/api/ssl-check.js b/api/ssl-check.js index 8f139c0..f87b66a 100644 --- a/api/ssl-check.js +++ b/api/ssl-check.js @@ -1,7 +1,7 @@ const https = require('https'); exports.handler = async function (event, context) { - const { url } = event.queryStringParameters; + const url = (event.queryStringParameters || event.query).url; const errorResponse = (message, statusCode = 500) => { return { diff --git a/api/tech-stack.js b/api/tech-stack.js index 6b4e86a..788a8f6 100644 --- a/api/tech-stack.js +++ b/api/tech-stack.js @@ -34,7 +34,7 @@ exports.handler = async (event, context, callback) => { } // Get URL from param - let url = event.queryStringParameters.url; + let url = (event.queryStringParameters || event.query).url; if (!/^https?:\/\//i.test(url)) { url = 'http://' + url; } diff --git a/api/trace-route.js b/api/trace-route.js index 08f8cbf..8d8525e 100644 --- a/api/trace-route.js +++ b/api/trace-route.js @@ -2,7 +2,7 @@ const traceroute = require('traceroute'); const url = require('url'); exports.handler = async function(event, context) { - const urlString = event.queryStringParameters.url; + const urlString = (event.queryStringParameters || event.query).url; try { if (!urlString) { diff --git a/api/whois-lookup.js b/api/whois-lookup.js index 3bca51f..3b6ba3e 100644 --- a/api/whois-lookup.js +++ b/api/whois-lookup.js @@ -24,7 +24,7 @@ const getBaseDomain = (url) => { exports.handler = async function(event, context) { - let url = event.queryStringParameters.url; + const url = (event.queryStringParameters || event.query).url; if (!url) { return errorResponse('URL query parameter is required.', 400);