This commit is contained in:
dsyoon
2026-01-04 12:33:00 +09:00
parent 2827880351
commit 4398f2929b
2 changed files with 22 additions and 6 deletions

View File

@@ -17,6 +17,14 @@ function normalizeExternalUrl(raw) {
return s; // leave as-is (could be relative path on same origin) return s; // leave as-is (could be relative path on same origin)
} }
function extractFirstHttpUrl(text) {
if (!text) return '';
const s = String(text);
// Capture first http/https URL until whitespace or common terminators.
const m = s.match(/https?:\/\/[^\s"'<>]+/i);
return m ? m[0] : '';
}
export default function AiNewsPage({ onNavigate }) { export default function AiNewsPage({ onNavigate }) {
const { user } = useAuth(); const { user } = useAuth();
const [news, setNews] = useState([]); const [news, setNews] = useState([]);
@@ -233,6 +241,14 @@ export default function AiNewsPage({ onNavigate }) {
onChange={(e) => setNewsUrl(e.target.value)} onChange={(e) => setNewsUrl(e.target.value)}
placeholder="뉴스 URL을 입력하세요" placeholder="뉴스 URL을 입력하세요"
style={{ width: 'calc(100% - 25px)', marginBottom: 8, padding: '10px 12px', borderRadius: 8, border: '1px solid #ffd6c2' }} style={{ width: 'calc(100% - 25px)', marginBottom: 8, padding: '10px 12px', borderRadius: 8, border: '1px solid #ffd6c2' }}
onPaste={(e) => {
const pasted = e.clipboardData?.getData('text') || '';
const url = extractFirstHttpUrl(pasted);
if (url) {
e.preventDefault();
setNewsUrl(url);
}
}}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
e.preventDefault(); e.preventDefault();