Image .src URL contains extra characters on mobile

This one’s been baffling me for days now so would really appreciate any help.

In my code I wish to strip off the ‘image:’ data from the url of an image. I have used code that has been put out in this forum previously, and has worked most of the time. This is the code:

export function getFullImageLogoURL(imageSRC) {
let strReturnImage = “” ;
if (imageSRC.startsWith( “image:” )) {
let wixImageURL = “” ;
wixImageURL = “https://static.wixstatic.com/media/” ;
let wixLocalURL = “” ;
wixLocalURL = imageSRC.replace( ‘image://v1/’ , ‘’ );
wixLocalURL = wixLocalURL.substr( 0 , wixLocalURL.indexOf( ‘/’ ));
strReturnImage = wixImageURL + wixLocalURL;
} else if (imageSRC.startsWith( “wix:image:” )) {
let wixImageURL = “” ;
wixImageURL = “https://static.wixstatic.com/media/” ;
let wixLocalURL = “” ;
wixLocalURL = imageSRC.replace( ‘wix:image://v1/’ , ‘’ );
wixLocalURL = wixLocalURL.substr( 0 , wixLocalURL.lastIndexOf( ‘/’ ));
strReturnImage = wixImageURL + wixLocalURL;
} else {
strReturnImage = imageSRC;
}
$w( “#logoText” ).text = strReturnImage;
return strReturnImage;
}

However, on occasions something strange is happening. When the url begins with ‘image’ (i.e. not wix:image), it sometimes adds some extra data into the strReturnImage field. E.g.:

fb4caf946c083f63b9adc6~mv2.jpeg" target=“_blank”> https://static.wixstatic.com/media/999dab_4bc fb4caf946c083f63b9adc6~mv2.jpeg

None of the characters before ‘https://…’ should be there. It only happens once the wixImageURL and wixLocal URL fields are appended; if I display this fields separately they are formatted as expected.

The other thing I have noticed is that it only ever does this when I use it on my mobile (IPhone). On my laptop the returned URL is again formatted as expected. It might be a browser issue rather than specifically to do with using a mobile, although I did try it on an Android phone too and also got the same issue.

Anyone seen anything like this before? Really would appreciate any help or at least some ideas to try out!

Many thanks
Steve

Id really like to understand whats happening, but would also welcome a solution to remove the surplus characters… thanks.