image-exporter 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3494,11 +3494,13 @@ async function getImageOptions(element, config) {
|
|
|
3494
3494
|
try {
|
|
3495
3495
|
const label = element.dataset.label || config.defaultImageLabel;
|
|
3496
3496
|
if (label === "") return config.defaultImageLabel;
|
|
3497
|
-
const endsWithSpecial = label
|
|
3497
|
+
const endsWithSpecial = /@\d+x$/.test(label);
|
|
3498
3498
|
let cleanedLabel = label;
|
|
3499
3499
|
const regex = /[^a-zA-Z0-9-_]/g;
|
|
3500
3500
|
if (endsWithSpecial) {
|
|
3501
|
-
|
|
3501
|
+
const match = label.match(/@\d+x$/);
|
|
3502
|
+
if (!match) return config.defaultImageLabel;
|
|
3503
|
+
cleanedLabel = label.slice(0, -match[0].length).replace(regex, "") + match[0];
|
|
3502
3504
|
} else {
|
|
3503
3505
|
cleanedLabel = label.replace(regex, "");
|
|
3504
3506
|
}
|
|
@@ -3499,11 +3499,13 @@
|
|
|
3499
3499
|
try {
|
|
3500
3500
|
const label = element.dataset.label || config.defaultImageLabel;
|
|
3501
3501
|
if (label === "") return config.defaultImageLabel;
|
|
3502
|
-
const endsWithSpecial = label
|
|
3502
|
+
const endsWithSpecial = /@\d+x$/.test(label);
|
|
3503
3503
|
let cleanedLabel = label;
|
|
3504
3504
|
const regex = /[^a-zA-Z0-9-_]/g;
|
|
3505
3505
|
if (endsWithSpecial) {
|
|
3506
|
-
|
|
3506
|
+
const match = label.match(/@\d+x$/);
|
|
3507
|
+
if (!match) return config.defaultImageLabel;
|
|
3508
|
+
cleanedLabel = label.slice(0, -match[0].length).replace(regex, "") + match[0];
|
|
3507
3509
|
} else {
|
|
3508
3510
|
cleanedLabel = label.replace(regex, "");
|
|
3509
3511
|
}
|
package/package.json
CHANGED
|
@@ -56,14 +56,16 @@ export async function getImageOptions(
|
|
|
56
56
|
if (label === "") return config.defaultImageLabel;
|
|
57
57
|
|
|
58
58
|
// Check if the label ends with '@#x'
|
|
59
|
-
const endsWithSpecial = label
|
|
59
|
+
const endsWithSpecial = /@\d+x$/.test(label);
|
|
60
60
|
let cleanedLabel = label;
|
|
61
61
|
|
|
62
62
|
// Allowed characters: a-z, A-Z, 0-9, -, _
|
|
63
|
-
// Remove all other characters using regex, except '
|
|
63
|
+
// Remove all other characters using regex, except '@Nx' at the end
|
|
64
64
|
const regex = /[^a-zA-Z0-9-_]/g;
|
|
65
65
|
if (endsWithSpecial) {
|
|
66
|
-
|
|
66
|
+
const match = label.match(/@\d+x$/);
|
|
67
|
+
if (!match) return config.defaultImageLabel;
|
|
68
|
+
cleanedLabel = label.slice(0, -match[0].length).replace(regex, "") + match[0];
|
|
67
69
|
} else {
|
|
68
70
|
cleanedLabel = label.replace(regex, "");
|
|
69
71
|
}
|