Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions library/src/containers/Operations/Operation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
channel: ChannelInterface;
}

// Construct the full relative URL, including path, query parameters to avoid path overwrite when
// location.hash is included
const relativePathname = `${window.location.pathname}${window.location.search}`;

Check warning on line 28 in library/src/containers/Operations/Operation.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=asyncapi_asyncapi-react&issues=AZrA72xuBnr_NG95uCwQ&open=AZrA72xuBnr_NG95uCwQ&pullRequest=1138

Check warning on line 28 in library/src/containers/Operations/Operation.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=asyncapi_asyncapi-react&issues=AZrA72xuBnr_NG95uCwR&open=AZrA72xuBnr_NG95uCwR&pullRequest=1138

export const Operation: React.FunctionComponent<Props> = (props) => {
const { type = PayloadType.SEND, operation, channelName, channel } = props;
const config = useConfig();
Expand All @@ -40,7 +44,6 @@
channel.parameters() !== undefined
? SchemaHelpers.parametersToSchema(channel.parameters())
: undefined;

return (
<div>
<div className="panel-item--center px-8">
Expand All @@ -53,7 +56,7 @@
{servers.map((server) => (
<li className="inline-block mt-2 mr-2" key={server.id()}>
<a
href={`${window.location.pathname}#${CommonHelpers.getIdentifier(
href={`${relativePathname}#${CommonHelpers.getIdentifier(
'server-' + server.id(),
config,
)}`}
Expand Down Expand Up @@ -406,7 +409,7 @@
{servers.map((server) => (
<li className="inline-block mt-2 mr-2" key={server.id()}>
<a
href={`${window.location.pathname}#${CommonHelpers.getIdentifier(
href={`${relativePathname}#${CommonHelpers.getIdentifier(
'server-' + server.id(),
config,
)}`}
Expand Down