fix: Escape regex for embeds (#3907)

Fixes #3899
This commit is contained in:
Apoorv Mishra
2022-08-02 14:10:11 +05:30
committed by GitHub
parent 00481d2bfc
commit 294521f162
56 changed files with 256 additions and 29 deletions

View File

@@ -44,6 +44,10 @@ describe("Abstract", () => {
});
test("to not be enabled elsewhere", () => {
expect("https://sharedgoabstract.com/f473".match(match)).toBe(null);
expect("https://share.goabstractacom/f473".match(match)).toBe(null);
expect("https://app1goabstract.com/share/f473".match(match2)).toBe(null);
expect("https://app.goabstractacom/share/f473".match(match2)).toBe(null);
expect("https://abstract.com".match(match)).toBe(null);
expect("https://goabstract.com".match(match)).toBe(null);
expect("https://app.goabstract.com".match(match)).toBe(null);

View File

@@ -4,8 +4,8 @@ import { EmbedProps as Props } from ".";
export default class Abstract extends React.Component<Props> {
static ENABLED = [
new RegExp("https?://share.(?:go)?abstract.com/(.*)$"),
new RegExp("https?://app.(?:go)?abstract.com/(?:share|embed)/(.*)$"),
new RegExp("https?://share\\.(?:go)?abstract\\.com/(.*)$"),
new RegExp("https?://app\\.(?:go)?abstract\\.com/(?:share|embed)/(.*)$"),
];
render() {

View File

@@ -11,6 +11,8 @@ describe("ClickUp", () => {
test("to not be enabled elsewhere", () => {
expect("https://share.clickup.com".match(match)).toBe(null);
expect("https://sharedclickup.com/a/b/c/d".match(match)).toBe(null);
expect("https://share.clickupdcom/a/b/c/d".match(match)).toBe(null);
expect("https://clickup.com/".match(match)).toBe(null);
expect("https://clickup.com/features".match(match)).toBe(null);
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https?://share.clickup.com/[a-z]/[a-z]/(.*)/(.*)$"
"^https?://share\\.clickup\\.com/[a-z]/[a-z]/(.*)/(.*)$"
);
export default class ClickUp extends React.Component<Props> {

View File

@@ -0,0 +1,10 @@
import Descript from "./Descript";
describe("Descript", () => {
const match = Descript.ENABLED[0];
test("to not be enabled elsewhere", () => {
expect("https://shareddescript.com/view/c9d8".match(match)).toBe(null);
expect("https://share.descriptdcom/view/c9d8".match(match)).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
export default class Descript extends React.Component<Props> {
static ENABLED = [new RegExp("https?://share.descript.com/view/(\\w+)$")];
static ENABLED = [new RegExp("https?://share\\.descript\\.com/view/(\\w+)$")];
render() {
const { matches } = this.props.attrs;

View File

@@ -18,5 +18,11 @@ describe("Figma", () => {
test("to not be enabled elsewhere", () => {
expect("https://www.figma.com".match(match)).toBe(null);
expect("https://www.figma.com/features".match(match)).toBe(null);
expect(
"https://wwww.figmaacom/file/LKQ4FJ4bTnCSjedbRpk931".match(match)
).toBe(null);
expect(
"https://wwwwfigma.com/file/LKQ4FJ4bTnCSjedbRpk931".match(match)
).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"https://([w.-]+.)?figma.com/(file|proto)/([0-9a-zA-Z]{22,128})(?:/.*)?$"
"https://([w.-]+\\.)?figma\\.com/(file|proto)/([0-9a-zA-Z]{22,128})(?:/.*)?$"
);
export default class Figma extends React.Component<Props> {

View File

@@ -22,6 +22,16 @@ describe("Gist", () => {
});
test("to not be enabled elsewhere", () => {
expect(
"https://gistigithub.com/n3n/eb51ada6308b539d388c8ff97711adfa".match(
match
)
).toBe(null);
expect(
"https://gist.githubbcom/n3n/eb51ada6308b539d388c8ff97711adfa".match(
match
)
).toBe(null);
expect("https://gist.github.com/tommoor".match(match)).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import styled from "styled-components";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https://gist.github.com/([a-zA-Z\\d](?:[a-zA-Z\\d]|-(?=[a-zA-Z\\d])){0,38})/(.*)$"
"^https://gist\\.github\\.com/([a-zA-Z\\d](?:[a-zA-Z\\d]|-(?=[a-zA-Z\\d])){0,38})/(.*)$"
);
class Gist extends React.Component<Props> {

View File

@@ -0,0 +1,14 @@
import Gliffy from "./Gliffy";
describe("Gliffy", () => {
const match = Gliffy.ENABLED[0];
test("to not be enabled elsewhere", () => {
expect("https://gotgliffy.com/go/share/c9d837d74182317".match(match)).toBe(
null
);
expect("https://go.gliffyycom/go/share/c9d837d74182317".match(match)).toBe(
null
);
});
});

View File

@@ -8,6 +8,6 @@ function Gliffy(props: Props) {
);
}
Gliffy.ENABLED = [new RegExp("https?://go.gliffy.com/go/share/(.*)$")];
Gliffy.ENABLED = [new RegExp("https?://go\\.gliffy\\.com/go/share/(.*)$")];
export default Gliffy;

View File

@@ -15,5 +15,15 @@ describe("GoogleCalendar", () => {
expect("https://calendar.google.com/calendar".match(match)).toBe(null);
expect("https://calendar.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://calendarrgoogle.com/calendar/embed?src=tom%40outline.com&ctz=America%2FSao_Paulo".match(
match
)
).toBe(null);
expect(
"https://calendar.googleecom/calendar/embed?src=tom%40outline.com&ctz=America%2FSao_Paulo".match(
match
)
).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https?://calendar.google.com/calendar/embed\\?src=(.*)$"
"^https?://calendar\\.google\\.com/calendar/embed\\?src=(.*)$"
);
export default class GoogleCalendar extends React.Component<Props> {

View File

@@ -15,5 +15,15 @@ describe("GoogleDataStudio", () => {
expect("https://datastudio.google.com/u/0/".match(match)).toBe(null);
expect("https://datastudio.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://datastudioogoogle.com/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBe(null);
expect(
"https://datastudio.googleecom/embed/reporting/aab01789-f3a2-4ff3-9cba-c4c94c4a92e8/page/7zFD".match(
match
)
).toBe(null);
});
});

View File

@@ -4,7 +4,7 @@ import Image from "../components/Image";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https?://datastudio.google.com/(embed|u/0)/reporting/(.*)/page/(.*)(/edit)?$"
"^https?://datastudio\\.google\\.com/(embed|u/0)/reporting/(.*)/page/(.*)(/edit)?$"
);
export default class GoogleDataStudio extends React.Component<Props> {

View File

@@ -30,5 +30,15 @@ describe("GoogleDocs", () => {
expect("https://docs.google.com/document".match(match)).toBe(null);
expect("https://docs.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://docssgoogle.com/document/d/e/2PACX-1vTdddHPoZ5M_47wmSHCoigRIt2cj_Pd-kgtaNQY6H0Jzn0_CVGbxC1GcK5IoNzU615lzguexFwxasAW/pubhtml".match(
match
)
).toBe(null);
expect(
"https://docs.googleecom/document/d/e/2PACX-1vTdddHPoZ5M_47wmSHCoigRIt2cj_Pd-kgtaNQY6H0Jzn0_CVGbxC1GcK5IoNzU615lzguexFwxasAW/pubhtml".match(
match
)
).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import Image from "../components/Image";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp("^https?://docs.google.com/document/(.*)$");
const URL_REGEX = new RegExp("^https?://docs\\.google\\.com/document/(.*)$");
export default class GoogleDocs extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -25,5 +25,15 @@ describe("GoogleDrawings", () => {
expect("https://docs.google.com/drawings".match(match)).toBe(null);
expect("https://docs.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://docssgoogle.com/drawings/d/1zDLtJ4HSCnjGCGSoCgqGe3F8p6o7R8Vjk8MDR6dKf-U/edit".match(
match
)
).toBe(null);
expect(
"https://docs.googleecom/drawings/d/1zDLtJ4HSCnjGCGSoCgqGe3F8p6o7R8Vjk8MDR6dKf-U/edit".match(
match
)
).toBe(null);
});
});

View File

@@ -4,7 +4,7 @@ import Image from "../components/Image";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https://docs.google.com/drawings/d/(.*)/(edit|preview)(.*)$"
"^https://docs\\.google\\.com/drawings/d/(.*)/(edit|preview)(.*)$"
);
export default class GoogleDrawings extends React.Component<Props> {

View File

@@ -25,5 +25,15 @@ describe("GoogleDrive", () => {
expect("https://drive.google.com/file".match(match)).toBe(null);
expect("https://drive.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://driveegoogle.com/file/d/1ohkOgmE8MiNx68u6ynBfYkgjeKu_x3ZK/view?usp=sharing".match(
match
)
).toBe(null);
expect(
"https://drive.googleecom/file/d/1ohkOgmE8MiNx68u6ynBfYkgjeKu_x3ZK/view?usp=sharing".match(
match
)
).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import Image from "../components/Image";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp("^https?://drive.google.com/file/d/(.*)$");
const URL_REGEX = new RegExp("^https?://drive\\.google\\.com/file/d/(.*)$");
export default class GoogleDrive extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -20,5 +20,15 @@ describe("GoogleSheets", () => {
expect("https://docs.google.com/spreadsheets".match(match)).toBe(null);
expect("https://docs.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://docssgoogle.com/spreadsheets/d/e/2PACX-1vTdddHPoZ5M_47wmSHCoigRIt2cj_Pd-kgtaNQY6H0Jzn0_CVGbxC1GcK5IoNzU615lzguexFwxasAW/pub".match(
match
)
).toBe(null);
expect(
"https://docs.googleecom/spreadsheets/d/e/2PACX-1vTdddHPoZ5M_47wmSHCoigRIt2cj_Pd-kgtaNQY6H0Jzn0_CVGbxC1GcK5IoNzU615lzguexFwxasAW/pub".match(
match
)
).toBe(null);
});
});

View File

@@ -3,7 +3,9 @@ import Frame from "../components/Frame";
import Image from "../components/Image";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp("^https?://docs.google.com/spreadsheets/d/(.*)$");
const URL_REGEX = new RegExp(
"^https?://docs\\.google\\.com/spreadsheets/d/(.*)$"
);
export default class GoogleSheets extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -25,5 +25,15 @@ describe("GoogleSlides", () => {
expect("https://docs.google.com/presentation".match(match)).toBe(null);
expect("https://docs.google.com".match(match)).toBe(null);
expect("https://www.google.com".match(match)).toBe(null);
expect(
"https://docssgoogle.com/presentation/d/e/2PACX-1vTdddHPoZ5M_47wmSHCoigRIt2cj_Pd-kgtaNQY6H0Jzn0_CVGbxC1GcK5IoNzU615lzguexFwxasAW/pub?start=false&loop=false&delayms=3000".match(
match
)
).toBe(null);
expect(
"https://docs.googleecom/presentation/d/e/2PACX-1vTdddHPoZ5M_47wmSHCoigRIt2cj_Pd-kgtaNQY6H0Jzn0_CVGbxC1GcK5IoNzU615lzguexFwxasAW/pub?start=false&loop=false&delayms=3000".match(
match
)
).toBe(null);
});
});

View File

@@ -3,7 +3,9 @@ import Frame from "../components/Frame";
import Image from "../components/Image";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp("^https?://docs.google.com/presentation/d/(.*)$");
const URL_REGEX = new RegExp(
"^https?://docs\\.google\\.com/presentation/d/(.*)$"
);
export default class GoogleSlides extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -0,0 +1,11 @@
import JSFiddle from "./JSFiddle";
describe("JSFiddle", () => {
const match = JSFiddle.ENABLED[0];
test("to not be enabled for invalid urls", () => {
expect("https://jsfiddleenet/go/share/c9d837d74182317".match(match)).toBe(
null
);
});
});

View File

@@ -20,6 +20,6 @@ function JSFiddle(props: Props) {
);
}
JSFiddle.ENABLED = [new RegExp("https?://jsfiddle.net/(.*)/(.*)$")];
JSFiddle.ENABLED = [new RegExp("https?://jsfiddle\\.net/(.*)/(.*)$")];
export default JSFiddle;

View File

@@ -28,5 +28,8 @@ describe("Loom", () => {
test("to not be enabled elsewhere", () => {
expect("https://www.useloom.com".match(match)).toBe(null);
expect("https://www.useloom.com/features".match(match)).toBe(null);
expect(
"https://www.loommcom/share/55327cbb265743f39c2c442c029277e0".match(match)
).toBe(null);
});
});

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = /^https:\/\/(www\.)?(use)?loom.com\/(embed|share)\/(.*)$/;
const URL_REGEX = /^https:\/\/(www\.)?(use)?loom\.com\/(embed|share)\/(.*)$/;
export default class Loom extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -10,5 +10,6 @@ describe("Marvel", () => {
test("to not be enabled elsewhere", () => {
expect("https://marvelapp.com".match(match)).toBe(null);
expect("https://marvelapp.com/features".match(match)).toBe(null);
expect("https://marvelapppcom/75hj91".match(match)).toBe(null);
});
});

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp("^https://marvelapp.com/([A-Za-z0-9-]{6})/?$");
const URL_REGEX = new RegExp("^https://marvelapp\\.com/([A-Za-z0-9-]{6})/?$");
export default class Marvel extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -42,5 +42,17 @@ describe("Mindmeister", () => {
test("to not be enabled elsewhere", () => {
expect("https://mindmeister.com".match(match)).toBe(null);
expect("https://www.mindmeister.com/pricing".match(match)).toBe(null);
expect("https://www.mmttt/326377934".match(match)).toBe(null);
expect(
"https://www.mindmeisterrcom/maps/public_map_shell/326377934/paper-digital-or-online-mind-mapping".match(
match
)
).toBe(null);
expect("https://wwwwmm.tt/326377934".match(match)).toBe(null);
expect(
"https://wwwwmindmeister.com/maps/public_map_shell/326377934/paper-digital-or-online-mind-mapping".match(
match
)
).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https://([w.-]+.)?(mindmeister.com|mm.tt)(/maps/public_map_shell)?/(\\d+)(\\?t=.*)?(/.*)?$"
"^https://([w.-]+\\.)?(mindmeister\\.com|mm\\.tt)(/maps/public_map_shell)?/(\\d+)(\\?t=.*)?(/.*)?$"
);
export default class Mindmeister extends React.Component<Props> {

View File

@@ -23,5 +23,8 @@ describe("Miro", () => {
expect("https://miro.com".match(match)).toBe(null);
expect("https://realtimeboard.com".match(match)).toBe(null);
expect("https://realtimeboard.com/features".match(match)).toBe(null);
expect(
"https://realtimeboarddcom/app/board/o9J_k0fwiss=".match(match)
).toBe(null);
});
});

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = /^https:\/\/(realtimeboard|miro).com\/app\/board\/(.*)$/;
const URL_REGEX = /^https:\/\/(realtimeboard|miro)\.com\/app\/board\/(.*)$/;
export default class RealtimeBoard extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -13,5 +13,11 @@ describe("ModeAnalytics", () => {
expect("https://modeanalytics.com".match(match)).toBe(null);
expect("https://modeanalytics.com/outline".match(match)).toBe(null);
expect("https://modeanalytics.com/outline/reports".match(match)).toBe(null);
expect(
"https://modeanalyticsscom/outline/reports/5aca06064f56".match(match)
).toBe(null);
expect(
"https://wwwwmodeanalytics.com/outline/reports/5aca06064f56".match(match)
).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https://([w.-]+.)?modeanalytics.com/(.*)/reports/(.*)$"
"^https://([w.-]+\\.)?modeanalytics\\.com/(.*)/reports/(.*)$"
);
export default class ModeAnalytics extends React.Component<Props> {

View File

@@ -0,0 +1,9 @@
import Otter from "./Otter";
describe("Otter", () => {
const match = Otter.ENABLED[0];
test("to not be enabled for invalid urls", () => {
expect("https://otterrai/s/c9d837d74182317".match(match)).toBe(null);
});
});

View File

@@ -14,6 +14,6 @@ function Otter(props: Props) {
);
}
Otter.ENABLED = [new RegExp("https?://otter.ai/[su]/(.*)$")];
Otter.ENABLED = [new RegExp("https?://otter\\.ai/[su]/(.*)$")];
export default Otter;

View File

@@ -0,0 +1,18 @@
import Pitch from "./Pitch";
describe("Pitch", () => {
const match = Pitch.ENABLED[0];
test("to not be enabled elsewhere", () => {
expect(
"https://appppitch.com/app/presentation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/player/c9d837d74182317".match(
match
)
).toBe(null);
expect(
"https://app.pitchhcom/app/presentation/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/player/c9d837d74182317".match(
match
)
).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https?://app.pitch.com/app/(?:presentation/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|public/player)/(.*)$"
"^https?://app\\.pitch\\.com/app/(?:presentation/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|public/player)/(.*)$"
);
export default class Pitch extends React.Component<Props> {

View File

@@ -18,5 +18,8 @@ describe("Prezi", () => {
test("to not be enabled elsewhere", () => {
expect("https://prezi.com".match(match)).toBe(null);
expect("https://prezi.com/pricing".match(match)).toBe(null);
expect("https://preziicom/view/39mn8Rn1ZkoeEKQCgk5C".match(match)).toBe(
null
);
});
});

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp("^https://prezi.com/view/(.*)$");
const URL_REGEX = new RegExp("^https://prezi\\.com/view/(.*)$");
export default class Prezi extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -23,5 +23,15 @@ describe("Spotify", () => {
expect("https://spotify.com".match(match)).toBe(null);
expect("https://open.spotify.com".match(match)).toBe(null);
expect("https://www.spotify.com".match(match)).toBe(null);
expect(
"https://opennspotify.com/track/29G1ScCUhgjgI0H72qN4DE?si=DxjEUxV2Tjmk6pSVckPDRg".match(
match
)
).toBe(null);
expect(
"https://open.spotifyycom/track/29G1ScCUhgjgI0H72qN4DE?si=DxjEUxV2Tjmk6pSVckPDRg".match(
match
)
).toBe(null);
});
});

View File

@@ -1,7 +1,7 @@
import * as React from "react";
import Frame from "../components/Frame";
const URL_REGEX = new RegExp("https?://open.spotify.com/(.*)$");
const URL_REGEX = new RegExp("https?://open\\.spotify\\.com/(.*)$");
import { EmbedProps as Props } from ".";
export default class Spotify extends React.Component<Props> {

View File

@@ -0,0 +1,10 @@
import Tldraw from "./Tldraw";
describe("Tldraw", () => {
const match = Tldraw.ENABLED[0];
test("to not be enabled elsewhere", () => {
expect("https://wwwwtldraw.com/r/c9d837d74182317".match(match)).toBe(null);
expect("https://www.tldrawwcom/r/c9d837d74182317".match(match)).toBe(null);
});
});

View File

@@ -14,6 +14,6 @@ function Tldraw(props: Props) {
);
}
Tldraw.ENABLED = [new RegExp("https?://www.tldraw.com/r/(.*)$")];
Tldraw.ENABLED = [new RegExp("https?://www\\.tldraw\\.com/r/(.*)$")];
export default Tldraw;

View File

@@ -0,0 +1,9 @@
import Trello from "./Trello";
describe("Trello", () => {
const match = Trello.ENABLED[0];
test("to not be enabled for invalid urls", () => {
expect("https://trelloocom/c/c9d837d74182317".match(match)).toBe(null);
});
});

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = /^https:\/\/trello.com\/(c|b)\/([^/]*)(.*)?$/;
const URL_REGEX = /^https:\/\/trello\.com\/(c|b)\/([^/]*)(.*)?$/;
export default class Trello extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -13,5 +13,7 @@ describe("Typeform", () => {
expect("https://www.typeform.com".match(match)).toBe(null);
expect("https://typeform.com/to/zvlr4L".match(match)).toBe(null);
expect("https://typeform.com/features".match(match)).toBe(null);
expect("https://beardymanntypeform.com/to/zvlr4L".match(match)).toBe(null);
expect("https://beardyman.typeformmcom/to/zvlr4L".match(match)).toBe(null);
});
});

View File

@@ -3,7 +3,7 @@ import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = new RegExp(
"^https://([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?).typeform.com/to/(.*)$"
"^https://([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)\\.typeform\\.com/to/(.*)$"
);
export default class Typeform extends React.Component<Props> {

View File

@@ -15,5 +15,6 @@ describe("Vimeo", () => {
expect("https://vimeo.com/features/video-marketing".match(match)).toBe(
null
);
expect("https://www.vimeoocom/265045525".match(match)).toBe(null);
});
});

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = /(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(\d+)(?:\/|\?)?([\d\w]+)?/;
const URL_REGEX = /(http|https)?:\/\/(www\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(\d+)(?:\/|\?)?([\d\w]+)?/;
export default class Vimeo extends React.Component<Props> {
static ENABLED = [URL_REGEX];

View File

@@ -0,0 +1,9 @@
import Whimsical from "./Whimsical";
describe("Whimsical", () => {
const match = Whimsical.ENABLED[0];
test("to not be enabled for invalid urls", () => {
expect("https://whimsicallcom/a-c9d837d74182317".match(match)).toBe(null);
});
});

View File

@@ -2,7 +2,7 @@ import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = /^https?:\/\/whimsical.com\/[0-9a-zA-Z-_~]*-([a-zA-Z0-9]+)\/?$/;
const URL_REGEX = /^https?:\/\/whimsical\.com\/[0-9a-zA-Z-_~]*-([a-zA-Z0-9]+)\/?$/;
export default class Whimsical extends React.Component<Props> {
static ENABLED = [URL_REGEX];