@uxf/resizer 10.0.0 → 11.7.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/index.js +3 -1
- package/index.ts +3 -1
- package/package.json +2 -2
- package/utils/get-source-filename.js +5 -1
- package/utils/get-source-filename.test.js +4 -0
- package/utils/get-source-filename.test.ts +7 -0
- package/utils/get-source-filename.ts +5 -1
- package/utils/parse-http-source.test.js +5 -0
- package/utils/parse-http-source.test.ts +5 -0
package/index.js
CHANGED
|
@@ -103,7 +103,9 @@ const resizerMiddleware = (config) => {
|
|
|
103
103
|
});
|
|
104
104
|
const trim = getTrim(params);
|
|
105
105
|
if (trim !== undefined) {
|
|
106
|
-
pipeline.trim(
|
|
106
|
+
pipeline.trim({
|
|
107
|
+
threshold: trim,
|
|
108
|
+
});
|
|
107
109
|
}
|
|
108
110
|
const quality = getQuality(params);
|
|
109
111
|
switch (params.toFormat) {
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/resizer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.7.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "UXF Resizer",
|
|
6
6
|
"author": "UXFans <dev@uxf.cz>",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"express": "4.18.2",
|
|
20
20
|
"path-to-regexp": "6.2.1",
|
|
21
21
|
"process": "0.11.10",
|
|
22
|
-
"sharp": "0.
|
|
22
|
+
"sharp": "0.33.1",
|
|
23
23
|
"yargs": "17.7.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -10,7 +10,11 @@ function getSourceFilename(source, params) {
|
|
|
10
10
|
const repairedParams = (0, repair_params_1.repairParams)(params);
|
|
11
11
|
(0, log_1.log)(repairedParams);
|
|
12
12
|
if (parsedHttpSource) {
|
|
13
|
-
|
|
13
|
+
// escape port
|
|
14
|
+
const domain = parsedHttpSource.domain.startsWith(":")
|
|
15
|
+
? parsedHttpSource.domain
|
|
16
|
+
: parsedHttpSource.domain.replace(":", "\\:");
|
|
17
|
+
const compiled = (0, path_to_regexp_1.compile)(`/${domain}/${parsedHttpSource.path}`, {})(repairedParams);
|
|
14
18
|
return `${parsedHttpSource.protocol}:/${compiled}`;
|
|
15
19
|
}
|
|
16
20
|
return (0, path_to_regexp_1.compile)(source, {})(repairedParams);
|
|
@@ -6,6 +6,10 @@ test("get source filename", () => {
|
|
|
6
6
|
filename: ["path", "to", "file"],
|
|
7
7
|
extension: "jpg",
|
|
8
8
|
})).toStrictEqual("https://domain.uxf.dev/path/to/file.jpg");
|
|
9
|
+
expect((0, get_source_filename_1.getSourceFilename)("http://localhost:3000/:filename+.:extension", {
|
|
10
|
+
filename: ["path", "to", "file"],
|
|
11
|
+
extension: "jpg",
|
|
12
|
+
})).toStrictEqual("http://localhost:3000/path/to/file.jpg");
|
|
9
13
|
expect((0, get_source_filename_1.getSourceFilename)("https://:url/:filename+.:extension", {
|
|
10
14
|
url: "domain-as-parameter.uxf.dev",
|
|
11
15
|
filename: ["path", "to", "file"],
|
|
@@ -8,6 +8,13 @@ test("get source filename", () => {
|
|
|
8
8
|
}),
|
|
9
9
|
).toStrictEqual("https://domain.uxf.dev/path/to/file.jpg");
|
|
10
10
|
|
|
11
|
+
expect(
|
|
12
|
+
getSourceFilename("http://localhost:3000/:filename+.:extension", {
|
|
13
|
+
filename: ["path", "to", "file"],
|
|
14
|
+
extension: "jpg",
|
|
15
|
+
}),
|
|
16
|
+
).toStrictEqual("http://localhost:3000/path/to/file.jpg");
|
|
17
|
+
|
|
11
18
|
expect(
|
|
12
19
|
getSourceFilename("https://:url/:filename+.:extension", {
|
|
13
20
|
url: "domain-as-parameter.uxf.dev",
|
|
@@ -9,7 +9,11 @@ export function getSourceFilename(source: string, params: Record<string, any>):
|
|
|
9
9
|
log(repairedParams);
|
|
10
10
|
|
|
11
11
|
if (parsedHttpSource) {
|
|
12
|
-
|
|
12
|
+
// escape port
|
|
13
|
+
const domain = parsedHttpSource.domain.startsWith(":")
|
|
14
|
+
? parsedHttpSource.domain
|
|
15
|
+
: parsedHttpSource.domain.replace(":", "\\:");
|
|
16
|
+
const compiled = compile(`/${domain}/${parsedHttpSource.path}`, {})(repairedParams);
|
|
13
17
|
return `${parsedHttpSource.protocol}:/${compiled}`;
|
|
14
18
|
}
|
|
15
19
|
|
|
@@ -7,6 +7,11 @@ test("parse source", () => {
|
|
|
7
7
|
domain: "domain.uxf.dev",
|
|
8
8
|
path: ":filename+.:extension",
|
|
9
9
|
});
|
|
10
|
+
expect((0, parse_http_source_1.parseHttpSource)("http://localhost:3000/:filename+.:extension")).toEqual({
|
|
11
|
+
protocol: "http",
|
|
12
|
+
domain: "localhost:3000",
|
|
13
|
+
path: ":filename+.:extension",
|
|
14
|
+
});
|
|
10
15
|
expect((0, parse_http_source_1.parseHttpSource)("https://:url/:filename+.:extension")).toEqual({
|
|
11
16
|
protocol: "https",
|
|
12
17
|
domain: ":url",
|
|
@@ -6,6 +6,11 @@ test("parse source", () => {
|
|
|
6
6
|
domain: "domain.uxf.dev",
|
|
7
7
|
path: ":filename+.:extension",
|
|
8
8
|
});
|
|
9
|
+
expect(parseHttpSource("http://localhost:3000/:filename+.:extension")).toEqual({
|
|
10
|
+
protocol: "http",
|
|
11
|
+
domain: "localhost:3000",
|
|
12
|
+
path: ":filename+.:extension",
|
|
13
|
+
});
|
|
9
14
|
expect(parseHttpSource("https://:url/:filename+.:extension")).toEqual({
|
|
10
15
|
protocol: "https",
|
|
11
16
|
domain: ":url",
|