Skip to content

Commit

Permalink
lint and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
accbjt committed Mar 20, 2024
1 parent 9b72933 commit 4650b01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion blocks/identity-block/components/login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const useLogin = ({
if (isOIDC) {
loginByOIDC();
} else {
window.location = redirectQueryParam || validatedLoggedInPageLoc;
const curentUrl = new URL(window.location.href);
const redirectUrl = redirectQueryParam || validatedLoggedInPageLoc;
// added search to handle editing in PB. Search appends the website query params.
window.location = `${redirectUrl}${curentUrl.search}`

Check warning

Code scanning / CodeQL

Client-side URL redirect Medium

Untrusted URL redirection depends on a
user-provided value
.

Check failure

Code scanning / CodeQL

Client-side cross-site scripting High

Cross-site scripting vulnerability due to
user-provided value
.
}
}
};
Expand Down
7 changes: 5 additions & 2 deletions blocks/identity-block/components/login/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe("useLogin()", () => {
beforeEach(() => {
Object.defineProperty(window, "location", {
writable: true,
value: {
href: 'http://localhost',
}
});
useIdentity.mockImplementation(() => ({
isInitialized: true,
Expand Down Expand Up @@ -68,14 +71,14 @@ describe("useLogin()", () => {
});

it("uses document referrer", async () => {
const referrerURL = "http://referrer.com";
const referrerURL = "http://referrer.com/article/1234";
Object.defineProperty(document, "referrer", {
value: referrerURL,
configurable: true,
});
await render(<Test />);
fireEvent.click(screen.getByRole("button"));
expect(window.location).toBe(referrerURL);
expect(window.location).toBe("/article/1234");
delete document.referrer;
});

Expand Down
2 changes: 1 addition & 1 deletion blocks/subscriptions-block/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@

@media (min-width: 320px) and (max-width: 480px) {
.b-paywall__overlay {
top: initial;
inset-block-start: initial;
}
}

0 comments on commit 4650b01

Please sign in to comment.