Skip to content

Commit

Permalink
🚑 Fix customDomain regex validation
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Aug 17, 2023
1 parent 454d320 commit fca5865
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ImportTypebotFromFileButton = ({
updatedAt: true,
})
.parse(typebot)
onNewTypebot(typebot)
onNewTypebot(typebot as Typebot)
} catch (err) {
console.error(err)
showToast({
Expand Down
4 changes: 3 additions & 1 deletion apps/builder/src/features/typebot/api/getPublishedTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { TRPCError } from '@trpc/server'
import { publicTypebotSchema } from '@typebot.io/schemas'
import { z } from 'zod'
import { isReadTypebotForbidden } from '../helpers/isReadTypebotForbidden'
import { parseInvalidTypebot } from '../helpers/parseInvalidTypebot'
import { PublicTypebot } from '@typebot.io/schemas'

export const getPublishedTypebot = authenticatedProcedure
.meta({
Expand Down Expand Up @@ -48,7 +50,7 @@ export const getPublishedTypebot = authenticatedProcedure

try {
const parsedTypebot = publicTypebotSchema.parse(
existingTypebot.publishedTypebot
parseInvalidTypebot(existingTypebot.publishedTypebot as PublicTypebot)
)

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Edge, Typebot, edgeSchema } from '@typebot.io/schemas'
import { Edge, PublicTypebot, Typebot, edgeSchema } from '@typebot.io/schemas'

export const parseInvalidTypebot = (typebot: Typebot): Typebot => ({
export const parseInvalidTypebot = (
typebot: Typebot | PublicTypebot
): Typebot | PublicTypebot => ({
...typebot,
version: typebot.version as null | '3' | '4' | '5',
edges: parseInvalidEdges(typebot.edges),
Expand Down
10 changes: 9 additions & 1 deletion packages/schemas/features/typebot/typebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const resultsTablePreferencesSchema = z.object({
const isPathNameCompatible = (str: string) =>
/^([a-z0-9]+-[a-z0-9]*)*$/.test(str) || /^[a-z0-9]*$/.test(str)

const isDomainNameWithPathNameCompatible = (str: string) =>
/^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?:\/[\w-\/]*)?)$/.test(
str
)

export const typebotSchema = z.object({
version: z.enum(['3', '4', '5']).nullable(),
id: z.string(),
Expand All @@ -56,7 +61,10 @@ export const typebotSchema = z.object({
icon: z.string().nullable(),
folderId: z.string().nullable(),
publicId: z.string().refine(isPathNameCompatible).nullable(),
customDomain: z.string().refine(isPathNameCompatible).nullable(),
customDomain: z
.string()
.refine(isDomainNameWithPathNameCompatible)
.nullable(),
workspaceId: z.string(),
resultsTablePreferences: resultsTablePreferencesSchema.nullable(),
isArchived: z.boolean(),
Expand Down

2 comments on commit fca5865

@vercel
Copy link

@vercel vercel bot commented on fca5865 Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

clo.closeer.work
cockroach.cr8.ai
desafioem21d.com
faqs.nigerias.io
feiraodehoje.com
georgemarttt.com
go.chatbotcv.com
haymanevents.com
kw.wpwakanda.com
localamor.online
lojamundobox.com
myrentalhost.com
silvercop.com.br
silvercop.online
stan.vselise.com
typebot.aloe.bot
vidalimentar.com
voicehelp.cr8.ai
web.bjogador.com
www.pantaflow.ai
zap.fundviser.in
analistamines.com
app.bouclidom.com
app.chatforms.net
appmillion.online
bot.cerograsa.com
bot.chatbotcv.com
bot.hostnation.de
bot.ketoolife.com
bot.maitempah.com
bot.phuonghub.com
bot.reviewamp.com
bot.reviewzer.com
bot.uluhub.com.br
cares.urlabout.me
chat.ezbooking.ai
chat.gaswadern.de
chat.gniorder.com
chat.onrentme.com
chat.rojie.online
chatdocidadao.com
chatwebonline.com
fmm.wpwakanda.com
footballmeetup.ie
gentleman-shop.fr
island.wakanda.is
k1.kandabrand.com
kp.pedroknoll.com
lb.ticketfute.com
metodoelev.com.br
ov1.wpwakanda.com
ov2.wpwakanda.com
linspecteuremma.site
malayanboosterhq.com
menu.numero-primo.it
menukb.wpwakanda.com
offer.botscientis.us
ore.barrettamario.it
sellmycarglasgow.com
stephanesampa.online
superglicemia.com.br
talkbot.agfunnel.com
tenorioadvogados.com
uppity.wpwakanda.com
83701274.21000000.lol
87186327.21000000.one
90945247.21000000.one
97320578.21000000.one
98650901.21000000.one
abutton.wpwakanda.com
acelera.maxbot.com.br
aidigitalmarketing.kr
atendimento.vrauu.com
bbutton.wpwakanda.com
bot.anovaerarb.online
bot.coachayongzul.com
bot.digitalpointer.id
bot.eikju.photography
bot.incusservices.com
bot.mejoralasalud.fun
bot.meuesocial.com.br
bot.mycompany.reviews
bot.outstandbrand.com
bot.ramonmatos.com.br
bot.robertohairlab.it
bot.sharemyreview.net
bot.synapsegameia.com
bot.truongnguyen.live
bots.baptistearno.com
botz.cloudsiteapp.com
cdd.searchcube.com.sg
chat.missarkansas.org
chatbot.ownacademy.co
chats.maisefetivo.com
claudio-barros.online
criar.somaperuzzo.com
gotasafrodisiacas.com
homerun.wpwakanda.com
mdb.assessoria.ademir
portaldasanalises.com

@vercel
Copy link

@vercel vercel bot commented on fca5865 Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.