refactor(RightClickRestorer): simplify setDomain logic
Replace nested if/try/catch with a single ternary expression. isUnsupportedPage() already handles invalid URLs, so new URL() is safe here. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -39,13 +39,7 @@ export function useRightClickRestorer(): UseRightClickRestorerReturn {
|
|||||||
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
||||||
const url = tab?.url;
|
const url = tab?.url;
|
||||||
|
|
||||||
if (url) {
|
setDomain(url ? new URL(url).hostname : '');
|
||||||
try {
|
|
||||||
setDomain(new URL(url).hostname);
|
|
||||||
} catch {
|
|
||||||
setDomain('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isUnsupportedPage(url)) {
|
if (isUnsupportedPage(url)) {
|
||||||
setIsUnsupported(true);
|
setIsUnsupported(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user