MetaMask / MetaMask/metamask-extension

[P1] util.js: relocate URL / origin helpers to url-utils (dedupe)

Open
#44,561 1 comment 0 reactions 0 assignees View on GitHub
exalate-duplicate INVALID-ISSUE-TEMPLATE mig-epic-70-child team-extension-platform
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

**Parent Epic:** [#44552 — `util.js` decomposition](https://github.com/MetaMask/metamask-extension/issues/44552)
**Source:** `ui/helpers/utils/util.js`
**Size:** L

---

## Problem

`getURL`, `getURLHost`, `getURLHostName`, `isExtensionUrl`, `stripHttpsSchemeWithoutPort` (+ private `stripHttpsScheme`), `isIpAddress`, `transformOriginToTitle` (fan-out cluster 10–12). Several are near-duplicates of `shared/lib/url-utils.ts`: `getURL`↔`getValidUrl`, `isIpAddress`↔`isLocalhostOrIPAddress`, `getURLHost*`↔`getDomain`/`onlyKeepHost`.

## Solution

Move to `shared/lib/url-utils.ts`, reconciling the duplicates (prefer the existing canonical helper where equivalent). Codemod the 10–12 import sites.

## Acceptance Criteria

- [ ] URL helpers consolidated in `url-utils.ts`; duplicates reconciled; originals deleted; imports rewired. Tests green.

Contributor guide

Open the contributing guide

Research direction

Start with ui/helpers/utils/util.js and shared/lib/url-utils.ts, comparing the listed URL helpers and their near-duplicates. Locate the 10–12 import sites, then reconcile the helpers in url-utils.ts and rewire those imports. Done means the originals are deleted, duplicates are consolidated, and the test suite is green.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.