File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -269,6 +269,7 @@ export const importUserExperienceCertification = async ({
269269 started_at : startedAt ,
270270 ended_at : endedAt ,
271271 flags,
272+ url,
272273 } = userExperience ;
273274
274275 const insertResult = await con
@@ -284,6 +285,7 @@ export const importUserExperienceCertification = async ({
284285 title,
285286 startedAt,
286287 endedAt,
288+ url,
287289 } ) ,
288290 ) ;
289291
@@ -312,6 +314,7 @@ export const importUserExperienceProject = async ({
312314 ended_at : endedAt ,
313315 skills,
314316 flags,
317+ url,
315318 } = userExperience ;
316319
317320 const insertResult = await con . getRepository ( UserExperienceProject ) . insert (
@@ -322,6 +325,7 @@ export const importUserExperienceProject = async ({
322325 description,
323326 startedAt,
324327 endedAt,
328+ url,
325329 } ) ,
326330 ) ;
327331
Original file line number Diff line number Diff line change @@ -16,3 +16,21 @@ export const paginationSchema = z.object({
1616} ) ;
1717
1818export type PaginationArgs = z . infer < typeof paginationSchema > ;
19+
20+ const urlStartRegexMatch = / ^ h t t p s ? : \/ \/ / ;
21+
22+ // match http(s) urls and partials like daily.dev (without protocol )
23+ export const urlParseSchema = z . preprocess (
24+ ( val ) => {
25+ if ( typeof val === 'string' ) {
26+ return val . match ( urlStartRegexMatch ) ? val : `https://${ val } ` ;
27+ }
28+
29+ return val ;
30+ } ,
31+ z . url ( {
32+ protocol : / ^ h t t p s ? $ / ,
33+ hostname : z . regexes . domain ,
34+ normalize : true ,
35+ } ) ,
36+ ) ;
Original file line number Diff line number Diff line change 11import z from 'zod' ;
22import { UserExperienceType } from '../../entity/user/experiences/types' ;
3- import { paginationSchema } from './common' ;
3+ import { paginationSchema , urlParseSchema } from './common' ;
44
55export const userExperiencesSchema = z
66 . object ( {
@@ -161,6 +161,7 @@ export const userExperienceCertificationImportSchema = z.object({
161161 started_at : z . coerce . date ( ) . default ( ( ) => new Date ( ) ) ,
162162 ended_at : z . coerce . date ( ) . nullish ( ) . default ( null ) ,
163163 flags : z . object ( { import : z . string ( ) } ) . partial ( ) . optional ( ) ,
164+ url : urlParseSchema . nullish ( ) ,
164165} ) ;
165166
166167export const userExperienceProjectImportSchema = z . object ( {
@@ -178,4 +179,5 @@ export const userExperienceProjectImportSchema = z.object({
178179 . nullish ( )
179180 . transform ( ( n ) => ( n === null ? undefined : n ) ) ,
180181 flags : z . object ( { import : z . string ( ) } ) . partial ( ) . optional ( ) ,
182+ url : urlParseSchema . nullish ( ) ,
181183} ) ;
You can’t perform that action at this time.
0 commit comments