File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,36 @@ export default function Word(props: WordProps): JSX.Element {
4646 />
4747 ) ;
4848 } else if ( type === StringObjType . url ) {
49+ const urlRegex = new RegExp ( "([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?" ) ;
50+ const targetUrl = urlRegex . exec ( value ) ?. [ 0 ] ;
51+ const stringUrl = { front : '' , url : '' , back : '' } ;
52+ if ( targetUrl ) {
53+ const targetUrlIndex = value . indexOf ( targetUrl ) ;
54+ if ( targetUrlIndex > 0 ) {
55+ stringUrl . front = value . slice ( 0 , targetUrlIndex ) ;
56+ }
57+ stringUrl . url = value . slice ( targetUrlIndex , targetUrlIndex + targetUrl . length ) ;
58+ if ( targetUrlIndex + targetUrl . length < value . length ) {
59+ stringUrl . back = value . slice ( targetUrlIndex + targetUrl . length ) ;
60+ }
61+ }
62+ if ( targetUrl ) {
63+ return [
64+ stringUrl . front ? stringUrl . front : '' ,
65+ stringUrl . url ? (
66+ < LinkLabel
67+ className = "sendbird-word__url"
68+ key = { uuidv4 ( ) }
69+ src = { stringUrl . url }
70+ type = { LabelTypography . BODY_1 }
71+ color = { isByMe ? LabelColors . ONCONTENT_1 : LabelColors . ONBACKGROUND_1 }
72+ >
73+ { stringUrl . url }
74+ </ LinkLabel >
75+ ) : null ,
76+ stringUrl . back ? stringUrl . back : '' ,
77+ ] ;
78+ }
4979 return (
5080 < LinkLabel
5181 className = "sendbird-word__url"
You can’t perform that action at this time.
0 commit comments