Files
MyIP/frontend/utils/legacy-tool-link.js
Claude 96525d2fc7 Chore: trim the branch — leftovers, redundancy, comments
A pass over every file the branch touched, after the iOS animation hunt
left tries and reverts behind it. Removed what nothing reaches: the
view-transition rule for a transition no code starts, an unreachable
guard in the transition hook, a no-op KeepAlive key branch, a sign-in
guard the menu already enforces, usage-dialog wrappers that only
forwarded to the store, a duplicated modifier-click check and card
filter (isPlainClick / listedTools), a test that hand-rolled
listedTools, a drawer-era fixture parameter. auth-flow.js folded into
auth-redirect.js. Comments cut to what the code cannot say itself —
file headers of a few lines, the measured iOS reasons, non-obvious
orderings — and stale ones fixed (Nav under KeepAlive, Home.vue
reusing DEFAULT_META, "from Nav", enabledCards). AGENTS.md sections
tightened to the code as it is now.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GbLTGMZ45MV78qd2tHoco
2026-10-05 16:50:16 +00:00

20 lines
942 B
JavaScript

// Legacy `/?tool=<slug>` links (the drawer era; still in bookmarks, shares and
// search results) → the tool's page, via the router's beforeEach. A known slug
// lands on /tools/<slug>, an unknown or malformed one on the homepage; other
// query params and the hash ride along. Returns null when there is nothing to
// rewrite. The redirect keeps the navigation's mode: a page load or history
// step replaces the entry, an in-app push stays a push.
import { TOOL_BY_SLUG } from '../data/tools.js';
const HOME_PATH = '/';
export const resolveLegacyToolLink = ({ path, query = {}, hash = '' } = {}) => {
if (path !== HOME_PATH || !query || !Object.hasOwn(query, 'tool')) return null;
const { tool, ...rest } = query;
const known = typeof tool === 'string' && TOOL_BY_SLUG.has(tool);
const location = { path: known ? `/tools/${tool}` : HOME_PATH, query: rest };
if (hash) location.hash = hash;
return location;
};