diff --git a/libs/components/editor-blocks/src/blocks/figma/index.ts b/libs/components/editor-blocks/src/blocks/figma/index.ts index b3e0b76b8d..3ed44c9c85 100644 --- a/libs/components/editor-blocks/src/blocks/figma/index.ts +++ b/libs/components/editor-blocks/src/blocks/figma/index.ts @@ -1,9 +1,9 @@ +import { Protocol } from '@toeverything/datasource/db-service'; import { AsyncBlock, BaseView, SelectBlock, } from '@toeverything/framework/virgo'; -import { Protocol, services } from '@toeverything/datasource/db-service'; import { FigmaView } from './FigmaView'; export class FigmaBlock extends BaseView { @@ -19,7 +19,10 @@ export class FigmaBlock extends BaseView { const tag_name = el.tagName; if (tag_name === 'A' && el.parentElement?.childElementCount === 1) { const href = el.getAttribute('href'); - if (href.indexOf('.figma.com') !== -1) { + const allowedHosts = ['www.figma.com']; + const host = new URL(href).host; + + if (allowedHosts.includes(host)) { return [ { type: this.type, diff --git a/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts b/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts index 47debf2175..6d980155fa 100644 --- a/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts +++ b/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts @@ -49,7 +49,7 @@ const weakSqlCreator = (weak_sql_express = ''): Promise => { constraints.push({ field: field.trim(), relation: relation.trim() as Relation, - value: pickValue(value.replace(/&&|&|;/, '').trim()), + value: pickValue(value.replace(/&&|&|;/g, '').trim()), }); /* meaningless return value */ diff --git a/libs/components/editor-blocks/src/blocks/youtube/index.ts b/libs/components/editor-blocks/src/blocks/youtube/index.ts index 363e7d78a9..42f22bcda4 100644 --- a/libs/components/editor-blocks/src/blocks/youtube/index.ts +++ b/libs/components/editor-blocks/src/blocks/youtube/index.ts @@ -1,9 +1,9 @@ +import { Protocol } from '@toeverything/datasource/db-service'; import { AsyncBlock, BaseView, SelectBlock, } from '@toeverything/framework/virgo'; -import { Protocol } from '@toeverything/datasource/db-service'; import { YoutubeView } from './YoutubeView'; export class YoutubeBlock extends BaseView { @@ -19,7 +19,10 @@ export class YoutubeBlock extends BaseView { const tag_name = el.tagName; if (tag_name === 'A' && el.parentElement?.childElementCount === 1) { const href = el.getAttribute('href'); - if (href.indexOf('.youtube.com') !== -1) { + const allowedHosts = ['www.youtu.be', 'www.youtube.com']; + const host = new URL(href).host; + + if (allowedHosts.includes(host)) { return [ { type: this.type, diff --git a/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts b/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts index ebc0c70be0..56f165a515 100644 --- a/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts +++ b/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts @@ -1,5 +1,7 @@ export const isYoutubeUrl = (url?: string): boolean => { - return url.includes('youtu.be') || url.includes('youtube.com'); + const allowedHosts = ['www.youtu.be', 'www.youtube.com']; + const host = new URL(url).host; + return allowedHosts.includes(host); }; const _regexp = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#&?]*).*/;