Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export default function LinkField({
const router = useRouter();
const { id } = useParams();

const cleanURL = (url: string): string => {
const match = url.match(/https?:\/\/[^\s]+/);
return match ? match[0].trim() : "";
};

useEffect(() => {
const validLinks = inputFields
.filter((field) => field.isValid)
Expand Down Expand Up @@ -114,31 +119,31 @@ export default function LinkField({
try {
const clipboardText = await navigator.clipboard.readText();
if (clipboardText.trim()) {
const cleanedText = cleanURL(clipboardText);
setInputFields((prevFields) =>
prevFields.map((fieldItem) =>
fieldItem.id === fieldId
? { ...fieldItem, text: clipboardText, isValid: false }
? { ...fieldItem, text: cleanedText, isValid: false }
: fieldItem
)
);

validateLink(fieldId, clipboardText, label);
validateLink(fieldId, cleanedText, label);
}
} catch (error) {
console.error("클립보드에서 텍스트를 읽는 데 실패했습니다:", error);
}
};

const handleInputChange = (fieldId: string, inputValue: string) => {
const cleanedValue = cleanURL(inputValue); // URL 정리
setInputFields((prevFields) =>
prevFields.map((fieldItem) =>
fieldItem.id === fieldId
? { ...fieldItem, text: inputValue, isValid: false, isTyping: true }
? { ...fieldItem, text: cleanedValue, isValid: false, isTyping: true }
: fieldItem
)
);

validateLink(fieldId, inputValue, label);
validateLink(fieldId, cleanedValue, label);
};

const handleFocus = (fieldId: string) => {
Expand Down
12 changes: 10 additions & 2 deletions fe/src/app/event-maps/[id]/load-mappin/forms/links/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export default function LinksPage() {
setIsFormComplete(isComplete);
}, [mapLinks, storeLinks, isChecked, isSubmitting]);

const cleanURL = (url: string): string => {
const match = url.match(/https?:\/\/[^\s]+/);
return match ? match[0].trim() : "";
};

const handleSubmit = async (e?: React.FormEvent) => {
if (e) e.preventDefault();

Expand All @@ -40,12 +45,15 @@ export default function LinksPage() {
return;
}

const cleanedMapLinks = mapLinks.map(cleanURL).filter(Boolean);
const cleanedStoreLinks = storeLinks.map(cleanURL).filter(Boolean);

const requestBody = {
uuid: id,
name,
password: pin,
bookmarkUrls: mapLinks,
storeUrls: storeLinks,
bookmarkUrls: cleanedMapLinks,
storeUrls: cleanedStoreLinks,
};

try {
Expand Down