Skip to content

Commit 599fbaf

Browse files
committed
fix embed naming
1 parent b82fde4 commit 599fbaf

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/cloud/components/Blocks/forms/EmbedForm.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,21 @@ const EmbedForm = ({ onSubmit }: EmbedFormProps) => {
2121
event.preventDefault()
2222
try {
2323
const nameRegex = new RegExp(
24-
/^(?:https?:\/\/)?(?:www\.)?([^\/]*)/,
24+
/^(?:https?:\/\/)?(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/,
2525
'gi'
2626
)
2727
const regexResult = nameRegex.exec(url)
28-
const name = regexResult != null ? capitalize(regexResult[1]) : 'Embed'
28+
29+
let name = 'Embed'
30+
if (regexResult != null) {
31+
let splits = regexResult[1].split('.')
32+
33+
if (splits.length > 0) {
34+
splits = splits.slice(0, -1)
35+
}
36+
37+
name = capitalize(splits.join(''))
38+
}
2939

3040
await onSubmit({
3141
name,

0 commit comments

Comments
 (0)