From 38be6688b95151f983d9d32dbeec4dffd4688605 Mon Sep 17 00:00:00 2001 From: Danny Roosevelt Date: Sun, 8 Sep 2024 13:52:33 -0700 Subject: [PATCH] PR feedback --- components/puppeteer/actions/common/common.mjs | 2 +- components/puppeteer/actions/get-html/get-html.mjs | 3 ++- components/puppeteer/actions/get-page-title/get-page-title.mjs | 3 ++- components/puppeteer/actions/get-pdf/get-pdf.mjs | 3 ++- .../puppeteer/actions/screenshot-page/screenshot-page.mjs | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/puppeteer/actions/common/common.mjs b/components/puppeteer/actions/common/common.mjs index 7a8d76b3b16a9..b42ee037a62ff 100644 --- a/components/puppeteer/actions/common/common.mjs +++ b/components/puppeteer/actions/common/common.mjs @@ -8,7 +8,7 @@ export default { }, }, methods: { - async run({ $ }) { + normalizeUrl() { let url = this.url; if (!url.startsWith("http")) { url = `https://${url}`; diff --git a/components/puppeteer/actions/get-html/get-html.mjs b/components/puppeteer/actions/get-html/get-html.mjs index ef23212df3ab3..b4af0c99cc5de 100644 --- a/components/puppeteer/actions/get-html/get-html.mjs +++ b/components/puppeteer/actions/get-html/get-html.mjs @@ -2,6 +2,7 @@ import puppeteer from "../../puppeteer.app.mjs"; import common from "../common/common.mjs"; export default { + ...common, key: "puppeteer-get-html", name: "Get HTML", description: @@ -13,7 +14,7 @@ export default { ...common.props, }, async run({ $ }) { - const url = await common.methods.run.call(this, { $ }); + const url = this.normalizeUrl(); const browser = await this.puppeteer.launch(); const page = await browser.newPage(); await page.goto(url); diff --git a/components/puppeteer/actions/get-page-title/get-page-title.mjs b/components/puppeteer/actions/get-page-title/get-page-title.mjs index 8f34900241f46..b85ab74337be7 100644 --- a/components/puppeteer/actions/get-page-title/get-page-title.mjs +++ b/components/puppeteer/actions/get-page-title/get-page-title.mjs @@ -2,6 +2,7 @@ import puppeteer from "../../puppeteer.app.mjs"; import common from "../common/common.mjs"; export default { + ...common, key: "puppeteer-get-page-title", name: "Get Page Title", description: @@ -13,7 +14,7 @@ export default { ...common.props, }, async run({ $ }) { - const url = await common.methods.run.call(this, { $ }); + const url = this.normalizeUrl(); const browser = await this.puppeteer.launch(); const page = await browser.newPage(); await page.goto(url); diff --git a/components/puppeteer/actions/get-pdf/get-pdf.mjs b/components/puppeteer/actions/get-pdf/get-pdf.mjs index c13359749329d..1754b7f2eca31 100644 --- a/components/puppeteer/actions/get-pdf/get-pdf.mjs +++ b/components/puppeteer/actions/get-pdf/get-pdf.mjs @@ -4,6 +4,7 @@ import common from "../common/common.mjs"; import fs from "fs"; export default { + ...common, key: "puppeteer-get-pdf", name: "Get PDF", description: @@ -168,7 +169,7 @@ export default { width: this.width, }; - const url = await common.methods.run.call(this, { $ }); + const url = this.normalizeUrl(); const browser = await this.puppeteer.launch(); const page = await browser.newPage(); await page.goto(url); diff --git a/components/puppeteer/actions/screenshot-page/screenshot-page.mjs b/components/puppeteer/actions/screenshot-page/screenshot-page.mjs index 9c3a5337cc2fc..4f8f54422bb0a 100644 --- a/components/puppeteer/actions/screenshot-page/screenshot-page.mjs +++ b/components/puppeteer/actions/screenshot-page/screenshot-page.mjs @@ -5,6 +5,7 @@ import fs from "fs"; import { ConfigurationError } from "@pipedream/platform"; export default { + ...common, key: "puppeteer-screenshot-page", name: "Screenshot a Page", description: @@ -155,7 +156,7 @@ export default { type: this.type, }; - const url = await common.methods.run.call(this, { $ }); + const url = this.normalizeUrl(); const browser = await this.puppeteer.launch(); const page = await browser.newPage(); await page.goto(url);