fix(mobile): strip XML comments before SvgXml parse to fix closing tag error

This commit is contained in:
AyrisAI
2026-08-21 00:02:37 +03:00
parent 4236ddb5ee
commit dd282f3987
+6 -1
View File
@@ -47,17 +47,22 @@ export default function QrScreen() {
// Inject the live QR code image directly into the SVG's #qr-placeholder group
// SVG içeriğine başka hiçbir şey dokunulmaz, sadece #qr-placeholder replace edilir
function buildSvgWithQr(svgRaw: string, pngBase64: string): string {
// react-native-svg XML parser <!-- yorum satırlarını --> desteklemez, parse hatası verir
const withoutComments = svgRaw.replace(/<!--[\s\S]*?-->/g, "");
const qrImgTag = `<g id="qr-placeholder" transform="translate(90, 215)">
<rect width="220" height="220" rx="20" fill="#FFFFFF"/>
<image href="data:image/png;base64,${pngBase64}" x="10" y="10" width="200" height="200" preserveAspectRatio="xMidYMid meet"/>
</g>`;
return svgRaw.replace(
return withoutComments.replace(
/<g id="qr-placeholder"[\s\S]*?<\/g>/,
qrImgTag
);
}
useEffect(() => {
(async () => {
const activeRest = await getActiveRestaurant();