fix interactive bug
This commit is contained in:
+6
-14
@@ -227,21 +227,13 @@ async function handleEnter() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, check if this URL already exists
|
// If the debounced lookup already found this URL exists, just show it
|
||||||
setStatus('checking…', '');
|
if (state.currentMeta && state.currentMeta.original_url === url) {
|
||||||
try {
|
setStatus('exists', 'ok');
|
||||||
const lookupRes = await apiGet('/api/lookup?url=' + encodeURIComponent(url));
|
return;
|
||||||
if (lookupRes.ok) {
|
}
|
||||||
// URL already exists — just show its metadata
|
|
||||||
const data = await lookupRes.json();
|
|
||||||
state.currentMeta = data;
|
|
||||||
renderMeta(data);
|
|
||||||
setStatus('exists', 'ok');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch { /* lookup failed, proceed to create */ }
|
|
||||||
|
|
||||||
// URL does not exist — attempt to create
|
// Create a new short URL
|
||||||
setStatus('creating…', '');
|
setStatus('creating…', '');
|
||||||
try {
|
try {
|
||||||
const res = await apiPost('/api/shorten', { url: url });
|
const res = await apiPost('/api/shorten', { url: url });
|
||||||
|
|||||||
Reference in New Issue
Block a user