mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-18 06:50:31 +02:00
feat: include google forms
This commit is contained in:
@@ -72,6 +72,8 @@ const ALLOWED_DOMAINS = new Set([
|
|||||||
"giphy.com",
|
"giphy.com",
|
||||||
"reddit.com",
|
"reddit.com",
|
||||||
"forms.microsoft.com",
|
"forms.microsoft.com",
|
||||||
|
"forms.gle",
|
||||||
|
"docs.google.com/forms",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const ALLOW_SAME_ORIGIN = new Set([
|
const ALLOW_SAME_ORIGIN = new Set([
|
||||||
@@ -86,6 +88,8 @@ const ALLOW_SAME_ORIGIN = new Set([
|
|||||||
"stackblitz.com",
|
"stackblitz.com",
|
||||||
"reddit.com",
|
"reddit.com",
|
||||||
"forms.microsoft.com",
|
"forms.microsoft.com",
|
||||||
|
"forms.gle",
|
||||||
|
"docs.google.com",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const createSrcDoc = (body: string) => {
|
export const createSrcDoc = (body: string) => {
|
||||||
@@ -335,15 +339,24 @@ const matchHostname = (
|
|||||||
allowedHostnames: Set<string> | string,
|
allowedHostnames: Set<string> | string,
|
||||||
): string | null => {
|
): string | null => {
|
||||||
try {
|
try {
|
||||||
const { hostname } = new URL(url);
|
const { hostname, pathname } = new URL(url);
|
||||||
|
|
||||||
const bareDomain = hostname.replace(/^www\./, "");
|
const bareDomain = hostname.replace(/^www\./, "");
|
||||||
|
|
||||||
if (allowedHostnames instanceof Set) {
|
if (allowedHostnames instanceof Set) {
|
||||||
|
// Check for exact domain match
|
||||||
if (ALLOWED_DOMAINS.has(bareDomain)) {
|
if (ALLOWED_DOMAINS.has(bareDomain)) {
|
||||||
return bareDomain;
|
return bareDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for path-based match (e.g., docs.google.com/forms)
|
||||||
|
const domainWithPath = `${bareDomain}${
|
||||||
|
pathname.split("/")[1] ? `/${pathname.split("/")[1]}` : ""
|
||||||
|
}`;
|
||||||
|
if (ALLOWED_DOMAINS.has(domainWithPath)) {
|
||||||
|
return domainWithPath;
|
||||||
|
}
|
||||||
|
|
||||||
const bareDomainWithFirstSubdomainWildcarded = bareDomain.replace(
|
const bareDomainWithFirstSubdomainWildcarded = bareDomain.replace(
|
||||||
/^([^.]+)/,
|
/^([^.]+)/,
|
||||||
"*",
|
"*",
|
||||||
@@ -399,6 +412,7 @@ export const embeddableURLValidator = (
|
|||||||
if (!url) {
|
if (!url) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validateEmbeddable != null) {
|
if (validateEmbeddable != null) {
|
||||||
if (typeof validateEmbeddable === "function") {
|
if (typeof validateEmbeddable === "function") {
|
||||||
const ret = validateEmbeddable(url);
|
const ret = validateEmbeddable(url);
|
||||||
|
Reference in New Issue
Block a user