We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b82fde4 commit 599fbafCopy full SHA for 599fbaf
1 file changed
src/cloud/components/Blocks/forms/EmbedForm.tsx
@@ -21,11 +21,21 @@ const EmbedForm = ({ onSubmit }: EmbedFormProps) => {
21
event.preventDefault()
22
try {
23
const nameRegex = new RegExp(
24
- /^(?:https?:\/\/)?(?:www\.)?([^\/]*)/,
+ /^(?:https?:\/\/)?(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/,
25
'gi'
26
)
27
const regexResult = nameRegex.exec(url)
28
- const name = regexResult != null ? capitalize(regexResult[1]) : 'Embed'
+
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
39
40
await onSubmit({
41
name,
0 commit comments