Skip to content

Commit 30ade71

Browse files
committed
Fix URLs.
1 parent e62f629 commit 30ade71

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

src/dotnet/APIView/ClientSPA/src/app/_components/review-page-options/review-page-options.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChange
22
import { ActivatedRoute, Router } from '@angular/router';
33
import { ToggleSwitchChangeEvent } from 'primeng/toggleswitch';
44
import { getQueryParams } from 'src/app/_helpers/router-helpers';
5-
import { CodeLineRowNavigationDirection, FULL_DIFF_STYLE, getAIReviewNotifiationInfo, mapLanguageAliases, TREE_DIFF_STYLE } from 'src/app/_helpers/common-helpers';
5+
import { CodeLineRowNavigationDirection, FULL_DIFF_STYLE, getAIReviewNotificationInfo, mapLanguageAliases, TREE_DIFF_STYLE } from 'src/app/_helpers/common-helpers';
66
import { Review } from 'src/app/_models/review';
77
import { APIRevision } from 'src/app/_models/revision';
88
import { ConfigService } from 'src/app/_services/config/config.service';
@@ -577,7 +577,7 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
577577
this.aiReviewGenerationState = 'Failed';
578578
this.generateAIReviewButtonText = 'Failed to generate copilot review';
579579
}
580-
const notificationInfo = getAIReviewNotifiationInfo(aiReviewUpdate, window.location.origin);
580+
const notificationInfo = getAIReviewNotificationInfo(aiReviewUpdate, window.location.origin);
581581
if (notificationInfo) {
582582
if (aiReviewUpdate.apirevisionId === this.activeAPIRevision?.id) {
583583
this.messageService.add(notificationInfo[1]);
@@ -642,7 +642,10 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
642642
}
643643

644644
getPullRequestsOfAssociatedAPIRevisionsUrl(pr: PullRequestModel) {
645-
return `${window.location.origin}/review/${pr.reviewId}?activeApiRevisionId=${pr.apiRevisionId}`;
645+
const baseHref = document.querySelector('base')?.getAttribute('href') || '/';
646+
const cleanOrigin = window.location.origin.replace(/\/$/, '');
647+
const cleanBaseHref = baseHref.replace(/\/$/, '');
648+
return `${cleanOrigin}${cleanBaseHref}/review/${pr.reviewId}?activeApiRevisionId=${pr.apiRevisionId}`;
646649
}
647650

648651
/**

src/dotnet/APIView/ClientSPA/src/app/_helpers/common-helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export function getLanguageCssSafeName(language: string): string {
2727
return "cplusplus";
2828
default:
2929
return language.toLowerCase();
30-
}
30+
}
3131
}
3232

3333
export function mapLanguageAliases(languages: Iterable<string>): string[] {
3434
const result: Set<string> = new Set<string>();
35-
35+
3636
for (const language of languages) {
3737
if (language === "TypeSpec" || language === "Cadl") {
3838
result.add("Cadl");
@@ -86,12 +86,15 @@ export function getSupportedLanguages(): any {
8686
];
8787
}
8888

89-
export function getAIReviewNotifiationInfo(jobInfo : AIReviewJobCompletedDto, origin: string): [SiteNotification, any] | undefined {
89+
export function getAIReviewNotificationInfo(jobInfo : AIReviewJobCompletedDto, origin: string): [SiteNotification, any] | undefined {
9090
if (jobInfo.status == 'Success' && jobInfo.noOfGeneratedComments > 0) {
9191
const messageData : ToastMessageData = {
9292
action: 'RefreshPage',
9393
};
94-
const pageUrl = `${origin}/review/${jobInfo.reviewId}?activeApiRevisionId=${jobInfo.apirevisionId}`;
94+
const baseHref = document.querySelector('base')?.getAttribute('href') || '/';
95+
const cleanOrigin = origin.replace(/\/$/, '');
96+
const cleanBaseHref = baseHref.replace(/\/$/, '');
97+
const pageUrl = `${cleanOrigin}${cleanBaseHref}/review/${jobInfo.reviewId}?activeApiRevisionId=${jobInfo.apirevisionId}`;
9598
const messagePart = (jobInfo.noOfGeneratedComments === 1) ? "comment" : "comments";
9699
const messageDetail = `Copilot generated ${jobInfo.noOfGeneratedComments} ${messagePart}.`;
97100
const summary = 'Copilot Comments';

src/dotnet/APIView/ClientSPA/src/app/app.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AIReviewJobCompletedDto } from './_dtos/aiReviewJobCompletedDto';
77
import { UserProfile } from './_models/userProfile';
88
import { SiteNotification } from './_models/notificationsModel';
99
import { SignalRService } from './_services/signal-r/signal-r.service';
10-
import { getAIReviewNotifiationInfo } from './_helpers/common-helpers';
10+
import { getAIReviewNotificationInfo } from './_helpers/common-helpers';
1111
import { NotificationsService } from './_services/notifications/notifications.service';
1212
import { ThemeHelper } from './_helpers/theme.helper';
1313

@@ -24,8 +24,8 @@ export class AppComponent implements OnInit{
2424
userProfile: UserProfile | undefined = undefined;
2525

2626
private destroy$ = new Subject<void>();
27-
28-
constructor(private userProfileService: UserProfileService, private configService: ConfigService,
27+
28+
constructor(private userProfileService: UserProfileService, private configService: ConfigService,
2929
private notificationsService: NotificationsService, private signalRService: SignalRService) { }
3030

3131
ngOnInit(): void {
@@ -50,7 +50,7 @@ export class AppComponent implements OnInit{
5050
}
5151

5252
this.configService.setAppTheme(theme);
53-
53+
5454
const body = document.body;
5555
if (theme !== "light-theme") {
5656
body.classList.remove("light-theme");
@@ -86,7 +86,7 @@ export class AppComponent implements OnInit{
8686
this.signalRService.onAIReviewUpdates().pipe(takeUntil(this.destroy$)).subscribe({
8787
next: (aiReviewUpdate: AIReviewJobCompletedDto) => {
8888
if (aiReviewUpdate.createdBy == this.userProfile?.userName) {
89-
const notificationInfo = getAIReviewNotifiationInfo(aiReviewUpdate, window.location.origin);
89+
const notificationInfo = getAIReviewNotificationInfo(aiReviewUpdate, window.location.origin);
9090
if (notificationInfo) {
9191
this.notificationsService.addNotification(notificationInfo[0]);
9292
}

0 commit comments

Comments
 (0)