@websolutespa/bom-mixer-image 1.0.8 → 1.8.0
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.
- package/CHANGELOG.md +15 -0
- package/dist/index.js +6 -3
- package/dist/index.mjs +6 -3
- package/package.json +3 -3
- package/src/image/image.handler.ts +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-image
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f8a1d97]
|
|
8
|
+
- @websolutespa/bom-core@1.8.0
|
|
9
|
+
|
|
10
|
+
## 1.0.9
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Fixing: downgrading eslint to v8.56.0
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @websolutespa/bom-core@1.7.8
|
|
17
|
+
|
|
3
18
|
## 1.0.8
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,7 @@ function imageHandler({ domains = [] }) {
|
|
|
103
103
|
width,
|
|
104
104
|
height: height ? height : void 0,
|
|
105
105
|
fit: import_sharp.default.fit.cover,
|
|
106
|
-
position: import_sharp.default.strategy.
|
|
106
|
+
position: import_sharp.default.strategy.attention,
|
|
107
107
|
withoutEnlargement: true
|
|
108
108
|
}).webp({
|
|
109
109
|
quality
|
|
@@ -170,8 +170,11 @@ function getCachedImage(pathname) {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
function urlToFileName(url) {
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
const segments = url.split("?");
|
|
174
|
+
const path2 = segments[0];
|
|
175
|
+
const query = segments[1];
|
|
176
|
+
let uniqueName = path2.replace("://", "_").replace(/\.|\/|\?|=/g, "_");
|
|
177
|
+
uniqueName = uniqueName.substring(0, uniqueName.lastIndexOf("_")) + (query ? "_" + query.replace(/\.|\/|\?|=/g, "_") : "") + "." + uniqueName.substring(uniqueName.lastIndexOf("_") + 1, uniqueName.length);
|
|
175
178
|
return uniqueName;
|
|
176
179
|
}
|
|
177
180
|
function isVercel() {
|
package/dist/index.mjs
CHANGED
|
@@ -67,7 +67,7 @@ function imageHandler({ domains = [] }) {
|
|
|
67
67
|
width,
|
|
68
68
|
height: height ? height : void 0,
|
|
69
69
|
fit: sharp.fit.cover,
|
|
70
|
-
position: sharp.strategy.
|
|
70
|
+
position: sharp.strategy.attention,
|
|
71
71
|
withoutEnlargement: true
|
|
72
72
|
}).webp({
|
|
73
73
|
quality
|
|
@@ -134,8 +134,11 @@ function getCachedImage(pathname) {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
function urlToFileName(url) {
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
const segments = url.split("?");
|
|
138
|
+
const path2 = segments[0];
|
|
139
|
+
const query = segments[1];
|
|
140
|
+
let uniqueName = path2.replace("://", "_").replace(/\.|\/|\?|=/g, "_");
|
|
141
|
+
uniqueName = uniqueName.substring(0, uniqueName.lastIndexOf("_")) + (query ? "_" + query.replace(/\.|\/|\?|=/g, "_") : "") + "." + uniqueName.substring(uniqueName.lastIndexOf("_") + 1, uniqueName.length);
|
|
139
142
|
return uniqueName;
|
|
140
143
|
}
|
|
141
144
|
function isVercel() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/bom-mixer-image",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Mixer Image module of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bom",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"lint": "eslint *.ts*",
|
|
17
17
|
"test": "jest",
|
|
18
|
-
"test-watch": "npm test -- --watch",
|
|
18
|
+
"test-watch": "npm test -- --watch --silent=false",
|
|
19
19
|
"coverage:integration": "npm run test -- --coverage",
|
|
20
20
|
"coverage": "run-s -c --silent coverage:*",
|
|
21
21
|
"compile": "tsup ./src/index.ts --format esm,cjs --dts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@websolutespa/bom-cli": "*",
|
|
34
34
|
"@websolutespa/test": "*",
|
|
35
35
|
"@websolutespa/tsconfig": "*",
|
|
36
|
-
"eslint": "^8.
|
|
36
|
+
"eslint": "^8.56.0",
|
|
37
37
|
"eslint-config-websolute": "*",
|
|
38
38
|
"npm-run-all": "^4.1.5",
|
|
39
39
|
"sharp": "0.30.4",
|
|
@@ -72,7 +72,7 @@ export function imageHandler({ domains = [] }: { domains: string[] }) {
|
|
|
72
72
|
width,
|
|
73
73
|
height: height ? height : undefined,
|
|
74
74
|
fit: sharp.fit.cover,
|
|
75
|
-
position: sharp.strategy.
|
|
75
|
+
position: sharp.strategy.attention,
|
|
76
76
|
withoutEnlargement: true,
|
|
77
77
|
})
|
|
78
78
|
.webp({
|
|
@@ -187,9 +187,13 @@ function getCachedImage(pathname: string): Promise<Buffer> {
|
|
|
187
187
|
// Defining the 'urlToFileName' function
|
|
188
188
|
function urlToFileName(url: string): string {
|
|
189
189
|
// Replacing useless characters with UNDERSCORE
|
|
190
|
-
|
|
190
|
+
const segments = url.split('?');
|
|
191
|
+
const path = segments[0];
|
|
192
|
+
const query = segments[1];
|
|
193
|
+
let uniqueName = path.replace('://', '_').replace(/\.|\/|\?|=/g, '_');
|
|
191
194
|
// Replacing last UNDERSCORE with a DOT
|
|
192
195
|
uniqueName = uniqueName.substring(0, uniqueName.lastIndexOf('_'))
|
|
196
|
+
+ (query ? '_' + query.replace(/\.|\/|\?|=/g, '_') : '')
|
|
193
197
|
+ '.' + uniqueName.substring(uniqueName.lastIndexOf('_') + 1, uniqueName.length);
|
|
194
198
|
// Returning the unique name
|
|
195
199
|
return uniqueName;
|