fix(mobile): strip XML comments before SvgXml parse to fix closing tag error
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user