profile-plus
Version:
32 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.replaceLocalhostWithSiteRoot = exports.generateRandomName = void 0;
const core_1 = require("@capacitor/core");
// currently use for generate
function generateRandomName(format) {
const timestamp = new Date().getTime();
const randomString = Math.random().toString(15).substring(7); // Generate a random string
return format
? `${timestamp}_${randomString}.${format}`
: `${timestamp}_${randomString}`;
}
exports.generateRandomName = generateRandomName;
/**
* Fixes the image path for Android devices during development.
* Replaces 'localhost' with the appropriate site root URL.
* @param croppedImage
* @returns
*/
function replaceLocalhostWithSiteRoot(croppedImage) {
let imageSrc = croppedImage;
if (imageSrc &&
process.env.NODE_ENV !== 'production' &&
core_1.Capacitor.getPlatform() === 'android') {
if (imageSrc.includes('localhost')) {
imageSrc = imageSrc.replace(/http\:\/\/localhost\:\d+/, process.env.SITE_ROOT);
}
}
return imageSrc;
}
exports.replaceLocalhostWithSiteRoot = replaceLocalhostWithSiteRoot;
//# sourceMappingURL=helper.js.map