Skip to content

Commit 60a82f7

Browse files
UFAL/Publisher search redirect not work #880 (#904)
Co-authored-by: milanmajchrak <90026355+milanmajchrak@users.noreply.github.com>
1 parent bdb4700 commit 60a82f7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/app/shared/clarin-item-box-view/clarin-item-box-view.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,21 @@ export class ClarinItemBoxViewComponent implements OnInit {
147147
this.itemUri = getItemPageRoute(this.item);
148148
this.itemDescription = this.item?.firstMetadataValue('dc.description');
149149
this.itemPublisher = this.item?.firstMetadataValue('dc.publisher');
150-
this.publisherRedirectLink = this.baseUrl + '/search?f.publisher=' + encodeURIComponent(this.itemPublisher)
151-
+ ',equals';
152150
this.itemDate = this.clarinDateService.composeItemDate(this.item);
153151

154152
await this.assignBaseUrl();
153+
this.publisherRedirectLink = this.getSearchEndpoint() + '?f.publisher=' + encodeURIComponent(this.itemPublisher)
154+
+ ',equals';
155155
this.getItemCommunity();
156156
this.loadItemLicense();
157157
this.getItemFilesSize();
158158
}
159159

160+
private getSearchEndpoint(): string {
161+
// Return the search endpoint URL for with the base URL. Remove trailing slashes to ensure a clean URL.
162+
return this.baseUrl.replace(/\/+$/, '') + '/search';
163+
}
164+
160165
private getItemFilesSize() {
161166
if (isNull(this.item)) {
162167
return;
@@ -193,8 +198,7 @@ export class ClarinItemBoxViewComponent implements OnInit {
193198
.pipe(getFirstSucceededRemoteDataPayload())
194199
.subscribe((community: Community) => {
195200
this.itemCommunity.next(community);
196-
const encodedRedirectLink = this.baseUrl +
197-
'/search?f.items_owning_community=' + encodeURIComponent(this.dsoNameService.getName(community)) + ',equals';
201+
const encodedRedirectLink = this.getSearchEndpoint() + '?f.items_owning_community=' + encodeURIComponent(this.dsoNameService.getName(community)) + ',equals';
198202
this.communitySearchRedirect.next(encodedRedirectLink);
199203
});
200204
});

0 commit comments

Comments
 (0)