Skip to content

Commit

Permalink
fix: In topbar menu the link Node Type redirection ko if '/#/' is inc…
Browse files Browse the repository at this point in the history
…luded - EXO-70678 - Meeds-io/meeds#1815 (#3687)

Before this change, When the href attribute contains a "#" followed by a
fragment identifier, the browser treats it as an anchor link and tries
to navigate to that fragment within the current page, instead of
navigating to a different URL
After this change, Handling the click and manually perform the
redirection

(cherry picked from commit 182baab)
  • Loading branch information
mkrout authored and ahamdi committed Apr 18, 2024
1 parent 8a8a92d commit d93012d
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
:aria-label="$t('topBar.navigation.menu.openMenu')"
role="tab"
@click.stop="checkLink(navigation, $event)"
@click="openUrl(navigationNodeUri, navigationNodeTarget)"
@change="updateNavigationState(navigation.uri)">
<span
class="text-truncate-3">
Expand Down Expand Up @@ -108,7 +109,7 @@ export default {
return !!this.navigation?.pageKey;
},
navigationNodeUri() {
return this.navigation?.pageLink && this.urlVerify(this.navigation?.pageLink) || `${this.baseSiteUri}${this.navigation.uri}`;
return this.navigation?.pageLink || `${this.baseSiteUri}${this.navigation.uri}`;
},
navigationNodeTarget() {
return this.navigation?.target === 'SAME_TAB' && '_self' || '_blank';
Expand Down Expand Up @@ -165,11 +166,13 @@ export default {
});
return childrenHasPage;
},
urlVerify(url) {
openUrl(url, target) {
if (!url.match(/^(https?:\/\/|javascript:|\/portal\/)/)) {
url = `//${url}`;
} else if (url.match(/^(\/portal\/)/)) {
url = `${window.location.origin}${url}`;
}
return url ;
window.open(url, target);
},
}
};
Expand Down

0 comments on commit d93012d

Please sign in to comment.