url입력 정제 추가
parent
5512d90a9e
commit
a853c714fd
|
|
@ -174,6 +174,26 @@ const SearchInputForm: React.FC<SearchInputFormProps> = ({
|
|||
}
|
||||
};
|
||||
|
||||
// 모바일 키보드 클립보드 추천 등 paste 이벤트 없이 여러 글자가 한 번에 들어오는 경우 처리
|
||||
const handleChange = (value: string) => {
|
||||
const isBulkInsert = value.length - inputValue.length > 1;
|
||||
if (isBulkInsert) {
|
||||
const extracted = extractUrl(value);
|
||||
if (extracted && extracted !== value.trim()) {
|
||||
applyInputChange(sanitizeUrlInput(extracted));
|
||||
return;
|
||||
}
|
||||
if (isUrlLike(value)) {
|
||||
const sanitized = sanitizeUrlInput(value);
|
||||
if (sanitized !== value) {
|
||||
applyInputChange(sanitized);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
applyInputChange(value);
|
||||
};
|
||||
|
||||
const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
|
||||
const pastedText = e.clipboardData.getData('text');
|
||||
|
||||
|
|
@ -227,7 +247,7 @@ const SearchInputForm: React.FC<SearchInputFormProps> = ({
|
|||
<input
|
||||
type="text"
|
||||
value={inputValue}
|
||||
onChange={(e) => applyInputChange(e.target.value)}
|
||||
onChange={(e) => handleChange(e.target.value)}
|
||||
onPaste={handlePaste}
|
||||
onFocus={() => {
|
||||
setIsFocused(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue