Skip to content

Commit

Permalink
chore(runway): cherry-pick fix: Fix invalid browser url crash (#11583)
Browse files Browse the repository at this point in the history
- fix: Fix invalid browser url crash (#11581)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

This PR fixes the crash in 7.32.0 for invalid URL in browser. The global
`URL` didn't catch invalid urls gracefully, so we are using the lib
`url-parser`

## **Related issues**

Fixes: #11479 

## **Manual testing steps**

1. Go to browser
2. Enter `httttps://app.uniswap.org`
3. Website shows invalid url scheme
4. App doesn't crash

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->



https://github.com/user-attachments/assets/2980c632-ed4b-48a4-976c-b1da54c590ce


## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding

Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling

guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
[e80a1e8](e80a1e8)

Co-authored-by: Cal Leung <[email protected]>
  • Loading branch information
runway-github[bot] and Cal-L authored Oct 2, 2024
1 parent e304797 commit 3337a75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/components/UI/AccountRightButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { MetaMetricsEvents } from '../../../core/Analytics';
import { AccountOverviewSelectorsIDs } from '../../../../e2e/selectors/AccountOverview.selectors';
import { useMetrics } from '../../../components/hooks/useMetrics';
import { useNetworkInfo } from '../../../selectors/selectedNetworkController';
import UrlParser from 'url-parse';

const styles = StyleSheet.create({
leftButton: {
Expand Down Expand Up @@ -138,7 +139,7 @@ const AccountRightButton = ({
const currentUrl = route.params?.url;
let hostname;
if (currentUrl) {
hostname = new URL(currentUrl).hostname;
hostname = new UrlParser(currentUrl)?.hostname;
}

const { networkName, networkImageSource } = useNetworkInfo(hostname);
Expand Down

0 comments on commit 3337a75

Please sign in to comment.