@@ -56,6 +56,19 @@ import {
5656} from '@/components/ui/dialog'
5757import { UserFormDialog } from './components/UserFormDialog'
5858
59+ function buildSubUrl ( subUrl ?: string , subId ?: string ) {
60+ if ( ! subUrl || ! subId ) return ''
61+
62+ if ( subId . startsWith ( 'http://' ) || subId . startsWith ( 'https://' ) ) {
63+ return subId
64+ }
65+
66+ const cleanBase = subUrl . replace ( / \/ + $ / , '' )
67+ const cleanId = subId . replace ( / ^ \/ + / , '' )
68+
69+ return `${ cleanBase } /${ cleanId } `
70+ }
71+
5972
6073interface ExpandedRow {
6174 [ key : string ] : boolean
@@ -645,7 +658,7 @@ export function DashboardPage() {
645658 < >
646659 < div className = "p-4 bg-white rounded-lg border" >
647660 < QRCodeSVG
648- value = { ` ${ dashboardData . sub_url } / ${ qrUser . sub_id ?. replace ( / ^ \/ + | \/ + $ / g , '' ) } ` }
661+ value = { buildSubUrl ( dashboardData . sub_url , qrUser . sub_id ) }
649662 size = { 200 }
650663 level = "M"
651664 />
@@ -655,7 +668,7 @@ export function DashboardPage() {
655668 < p > < strong > User:</ strong > { qrUser ?. username } </ p >
656669 </ div >
657670 < div className = "p-3 bg-muted rounded-md break-all text-xs font-mono" >
658- { ` ${ dashboardData . sub_url } / ${ qrUser . sub_id ?. replace ( new RegExp ( `^ ${ dashboardData . sub_url . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g , '\\$&' ) } ` ) , '' ) . replace ( / ^ \/ + / , '' ) } ` }
671+ { buildSubUrl ( dashboardData . sub_url , qrUser . sub_id ) }
659672 </ div >
660673 </ div >
661674 </ >
@@ -780,7 +793,7 @@ function DetailsRow({
780793 { subUrl && user . sub_id && (
781794 < div className = "p-3 bg-background rounded-md border" >
782795 < div className = "text-xs text-muted-foreground mb-1" > Subscription Link:</ div >
783- < div className = "text-xs font-mono break-all" > { ` ${ subUrl } / ${ user . sub_id ?. replace ( new RegExp ( `^ ${ subUrl . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g , '\\$&' ) } ` ) , '' ) . replace ( / ^ \/ + / , '' ) } ` } </ div >
796+ { buildSubUrl ( subUrl , user . sub_id ) }
784797 </ div >
785798 ) }
786799 < div className = "flex flex-wrap gap-2 pt-2" >
@@ -797,7 +810,8 @@ function DetailsRow({
797810 size = "sm"
798811 variant = "outline"
799812 onClick = { ( ) => {
800- navigator . clipboard . writeText ( `${ subUrl } /${ user . sub_id ?. replace ( new RegExp ( `^${ subUrl . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) } ` ) , '' ) . replace ( / ^ \/ + / , '' ) || user . sub_id } ` )
813+ navigator . clipboard . writeText ( buildSubUrl ( subUrl , user . sub_id ) )
814+
801815 } }
802816 >
803817 < Copy className = "h-4 w-4 mr-2" />
@@ -968,7 +982,8 @@ function MobileUserCard({
968982 className = "flex-1 min-w-[80px]"
969983 onClick = { ( e ) => {
970984 e . stopPropagation ( )
971- navigator . clipboard . writeText ( `${ subUrl } /${ user . sub_id ?. replace ( new RegExp ( `^${ subUrl . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) } ` ) , '' ) . replace ( / ^ \/ + / , '' ) || user . sub_id } ` )
985+ navigator . clipboard . writeText ( buildSubUrl ( subUrl , user . sub_id ) )
986+
972987 } }
973988 >
974989 < Copy className = "h-3 w-3 mr-1" />
0 commit comments