Skip to content

Commit

Permalink
fix(components): use base tag href if defined for post-icon (#4069) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
leagrdv authored Dec 5, 2024
1 parent 57fd1b5 commit ad92ead
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sharp-bobcats-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-components': patch
---

Made `post-icon` component use base tag href to define location of icons folder.
3 changes: 2 additions & 1 deletion packages/components/src/components/post-icon/post-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export class PostIcon {
.querySelector('meta[name="design-system-settings"][data-post-icon-base]')
?.getAttribute('data-post-icon-base') ?? null;

const fileBase = `${this.base ?? metaBase ?? CDN_URL}/`.replace(/\/\/$/, '/');
const baseHref = document.getElementsByTagName('base')[0]?.href;
const fileBase = `${this.base ?? metaBase ?? baseHref ?? CDN_URL}/`.replace(/\/\/$/, '/');
const fileName = `${this.name}.svg`;
const filePath = `${fileBase}${fileName}`;

Expand Down

0 comments on commit ad92ead

Please sign in to comment.