Skip to content

Commit

Permalink
Added detection for invalid web app URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
erickoledadevrel committed Aug 28, 2023
1 parent 1ba3464 commit e27a6fc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps-script/packs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ScriptSchema } from "./schemas";
const DefaultRequestMethod = "GET";
const SupportedRequestMethods = ["GET", "POST"];
const DefaultRequestContentType = "text/plain";
const WebAppUrlRegex = new RegExp("^https://script.google.com/(a/)?macros/([^/]+/)?s/([^/]+)/exec");

export const pack = coda.newPack();

Expand Down Expand Up @@ -123,6 +124,9 @@ pack.addFormula({
if (!SupportedRequestMethods.includes(method)) {
throw new coda.UserVisibleError(`Invalid method: ${method}`);
}
if (!url || !url.match(WebAppUrlRegex)) {
throw new coda.UserVisibleError(`Invalid web app URL: ${url}`);
}
if (parameters) {
let parsed;
try {
Expand Down

0 comments on commit e27a6fc

Please sign in to comment.