Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions express/code/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export function getMobileOperatingSystem() {
return 'unknown';
}

export function isWindows(userAgent) {
const ua = userAgent ?? window.navigator?.userAgent ?? '';
return /\bwindows nt\b/i.test(ua);
}

export async function getRedirectUri() {
const { getConfig } = await import(`${getLibs()}/utils/utils.js`);
if (getMetadata('adobe-home-redirect') === 'on') {
Expand Down
20 changes: 15 additions & 5 deletions express/code/scripts/utils/frictionless-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLibs } from '../utils.js';
import { getLibs, isWindows } from '../utils.js';

// Shared constants and configurations for frictionless quick actions
const JPG = 'jpg';
Expand Down Expand Up @@ -82,6 +82,16 @@ const getMergeVideosCfg = () => ({
},
});

const getHeicInputCheck = (...types) => (input, fileName) => {
const baseCheck = getBaseImgCfg(...types).input_check(input);
if (baseCheck || input === `image/${HEIC}`) return true;
if (!input && fileName && isWindows()) {
const ext = fileName.split('.').pop()?.toLowerCase();
return types.includes(ext);
}
return false;
};

// Shared QA configurations
export const QA_CONFIGS = {
'convert-to-jpg': {
Expand Down Expand Up @@ -115,11 +125,11 @@ export const QA_CONFIGS = {
'edit-image': { ...getBaseImgCfg(JPG, JPEG, PNG, WEBP) },
'heic-to-jpg': {
...getBaseImgCfg(PNG, WEBP, HEIC),
input_check: (input) => getBaseImgCfg(PNG, WEBP, HEIC).input_check(input) || input === `image/${HEIC}`,
input_check: getHeicInputCheck(PNG, WEBP, HEIC),
},
'heic-to-png': {
...getBaseImgCfg(JPG, JPEG, WEBP, HEIC),
input_check: (input) => getBaseImgCfg(JPG, JPEG, WEBP, HEIC).input_check(input) || input === `image/${HEIC}`,
input_check: getHeicInputCheck(JPG, JPEG, WEBP, HEIC),
},
};

Expand Down Expand Up @@ -433,7 +443,7 @@ export function executeQuickAction(
export async function getErrorMsg(files, quickAction, replaceKey, getConfig) {
let msg;
const isNotValid = Array.from(files).some(
(file) => !QA_CONFIGS[quickAction].input_check(file.type),
(file) => !QA_CONFIGS[quickAction].input_check(file.type, file.name),
);
if (isNotValid) {
msg = await replaceKey('file-type-not-supported', getConfig());
Expand All @@ -449,7 +459,7 @@ export async function processFileForQuickAction(
) {
const maxSize = QA_CONFIGS[quickAction].max_size ?? 40 * 1024 * 1024;

if (QA_CONFIGS[quickAction].input_check(file.type) && file.size <= maxSize) {
if (QA_CONFIGS[quickAction].input_check(file.type, file.name) && file.size <= maxSize) {
const isVideo = QA_CONFIGS[quickAction].group === 'video';
if (isVideo) {
window.history.pushState({ hideFrictionlessQa: true }, '', '');
Expand Down
Loading