diff --git a/src/mobile-main.ts b/src/mobile-main.ts index 51cfdb6..48d0e9f 100644 --- a/src/mobile-main.ts +++ b/src/mobile-main.ts @@ -81,7 +81,21 @@ document.addEventListener('DOMContentLoaded', () => { function processScannedCode(rawCode: string) { // QR 코드 인쇄 폼 등으로 인한 개행 문자(\r, \n) 및 모든 공백 문자(\s)를 제거 - const code = rawCode.replace(/[\r\n]/g, '').replace(/\s+/g, '').trim(); + let code = rawCode.replace(/[\r\n]/g, '').replace(/\s+/g, '').trim(); + + // 만약 스캔된 텍스트가 전체 URL 주소 형식이라면 파라미터 값만 추출하여 정제 + if (code.includes('http://') || code.includes('https://') || code.includes('/mobile')) { + try { + const urlObj = new URL(code, window.location.origin); + const locParam = urlObj.searchParams.get('loc'); + const assetParam = urlObj.searchParams.get('asset'); + + if (locParam) code = locParam; + else if (assetParam) code = assetParam; + } catch (e) { + console.error("URL 파싱 에러:", e); + } + } // 1. Check if the code is a physical location code if (code.startsWith('LOC-')) {