@@ -75,7 +75,7 @@ export class NewCopilotSurveyComponent implements OnInit {
7575 surveys : Survey [ ] = [ ] ;
7676 orgFromApp = '' ;
7777 hasQueryParams = false ;
78-
78+
7979 // Add these properties to fix the template error
8080 repo = '' ;
8181 prNumber = '' ;
@@ -112,7 +112,7 @@ export class NewCopilotSurveyComponent implements OnInit {
112112 reason : new FormControl ( '' ) ,
113113 timeUsedFor : new FormControl ( '' , Validators . required )
114114 } ) ;
115-
115+
116116 // Set up the search pipeline
117117 this . filteredMembers$ = this . searchTerms . pipe (
118118 debounceTime ( 300 ) ,
@@ -121,7 +121,7 @@ export class NewCopilotSurveyComponent implements OnInit {
121121 if ( term . length < 2 ) {
122122 return of ( [ ] ) ;
123123 }
124-
124+
125125 this . isLoading$ . next ( true ) ;
126126 return this . membersService . searchMembersByLogin ( term ) . pipe (
127127 catchError ( error => {
@@ -144,43 +144,47 @@ export class NewCopilotSurveyComponent implements OnInit {
144144 this . searchTerms . next ( value ) ;
145145 }
146146 } ) ;
147-
147+
148148 // Initial form setup from query params
149149 this . route . queryParams . subscribe ( params => {
150150 this . params = params ;
151-
151+
152152 // Set hasQueryParams BEFORE setting values to avoid form validation errors
153153 this . hasQueryParams = ! ! ( params [ 'author' ] || params [ 'repo' ] || params [ 'prno' ] || params [ 'url' ] ) ;
154-
154+
155155 // Pre-fill the form only if params exist
156156 if ( params [ 'author' ] ) {
157157 this . surveyForm . get ( 'userId' ) ?. setValue ( params [ 'author' ] ) ;
158-
158+
159159 // Manually trigger activity lookup for pre-filled userID
160160 this . loadUserCopilotActivity ( params [ 'author' ] ) ;
161161 }
162-
162+
163163 if ( params [ 'repo' ] ) {
164164 this . surveyForm . get ( 'repo' ) ?. setValue ( params [ 'repo' ] ) ;
165165 this . repo = params [ 'repo' ] ; // Immediately set the property for template access
166166 }
167-
167+
168168 if ( params [ 'prno' ] ) {
169169 this . surveyForm . get ( 'prNumber' ) ?. setValue ( params [ 'prno' ] ) ;
170170 this . prNumber = params [ 'prno' ] ; // Immediately set the property for template access
171171 }
172-
172+
173173 // Handle GitHub URL parsing
174- if ( params [ 'url' ] && params [ 'url' ] . includes ( 'github.com' ) ) {
175- const { org, repo, prNumber } = this . parseGitHubPRUrl ( params [ 'url' ] ) ;
176- this . orgFromApp = org ;
177- if ( ! params [ 'repo' ] && repo ) {
178- this . surveyForm . get ( 'repo' ) ?. setValue ( repo ) ;
179- this . repo = repo ; // Immediately set the property for template access
180- }
181- if ( ! params [ 'prno' ] && prNumber ) {
182- this . surveyForm . get ( 'prNumber' ) ?. setValue ( prNumber ) ;
183- this . prNumber = String ( prNumber ) ; // Immediately set the property for template access
174+ if ( params [ 'url' ] ) {
175+ const parsedUrl = new URL ( params [ 'url' ] ) ;
176+ const allowedHosts = [ 'github.com' , 'www.github.com' ] ;
177+ if ( allowedHosts . includes ( parsedUrl . host ) ) {
178+ const { org, repo, prNumber } = this . parseGitHubPRUrl ( params [ 'url' ] ) ;
179+ this . orgFromApp = org ;
180+ if ( ! params [ 'repo' ] && repo ) {
181+ this . surveyForm . get ( 'repo' ) ?. setValue ( repo ) ;
182+ this . repo = repo ;
183+ }
184+ if ( ! params [ 'prno' ] && prNumber ) {
185+ this . surveyForm . get ( 'prNumber' ) ?. setValue ( prNumber ) ;
186+ this . prNumber = String ( prNumber ) ;
187+ }
184188 }
185189 }
186190 } ) ;
@@ -223,12 +227,12 @@ export class NewCopilotSurveyComponent implements OnInit {
223227 this . surveyForm . get ( 'repo' ) ?. valueChanges . subscribe ( value => {
224228 this . repo = value ;
225229 } ) ;
226-
230+
227231 this . surveyForm . get ( 'prNumber' ) ?. valueChanges . subscribe ( value => {
228232 this . prNumber = value ;
229233 } ) ;
230234 }
231-
235+
232236 loadHistoricalReasons ( ) {
233237 this . copilotSurveyService . getAllSurveys ( {
234238 reasonLength : 20 ,
@@ -283,7 +287,7 @@ export class NewCopilotSurveyComponent implements OnInit {
283287
284288 // Use fallbacks for org and repo
285289 const { org, repo, prNumber } = this . parseGitHubPRUrl ( this . params [ 'url' ] || '' ) ;
286-
290+
287291 const survey = {
288292 id : this . id ,
289293 userId : finalUserId ,
@@ -427,7 +431,7 @@ export class NewCopilotSurveyComponent implements OnInit {
427431 } else {
428432 // Invalid user (and not caught by catchError, e.g., API returned null)
429433 if ( ! userIdControl ?. hasError ( 'invalidUserId' ) ) { // Avoid overwriting existing error
430- userIdControl ?. setErrors ( { invalidUserId : true } ) ;
434+ userIdControl ?. setErrors ( { invalidUserId : true } ) ;
431435 }
432436 }
433437 } ) ;
@@ -442,7 +446,7 @@ export class NewCopilotSurveyComponent implements OnInit {
442446 // Calculate 7 days ago from now
443447 const since = dayjs ( ) . subtract ( 7 , 'day' ) . toISOString ( ) ;
444448 const until = dayjs ( ) . toISOString ( ) ;
445-
449+
446450 this . seatService . getSeatByLogin ( login , { since, until } ) . subscribe ( {
447451 next : ( activity : Seat [ ] ) => {
448452 if ( activity && activity . length > 0 ) {
@@ -453,18 +457,18 @@ export class NewCopilotSurveyComponent implements OnInit {
453457 // Round to the hour to group closely timed activities
454458 const hourTimestamp = dayjs ( item . last_activity_at ) . startOf ( 'hour' ) . format ( ) ;
455459 uniqueTimestamps . add ( hourTimestamp ) ;
456-
460+
457461 // This property doesn't exist on the item because it's not in the
458462 // Seat type definition in your service
459- this . assignee_id = item . assignee_id ;
463+ this . assignee_id = item . assignee_id ;
460464 }
461465 } ) ;
462-
466+
463467 // Calculate total hours of activity
464468 this . copilotActivityHours = uniqueTimestamps . size ;
465469 this . hasCopilotActivity = this . copilotActivityHours > 0 ;
466-
467-
470+
471+
468472 // Pre-select "Yes" for usedCopilot if there's recent activity
469473 if ( this . hasCopilotActivity ) {
470474 this . surveyForm . get ( 'usedCopilot' ) ?. setValue ( true ) ;
0 commit comments