@uxf/resizer 10.0.0 → 10.10.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/resizer",
3
- "version": "10.0.0",
3
+ "version": "10.10.1",
4
4
  "main": "index.js",
5
5
  "description": "UXF Resizer",
6
6
  "author": "UXFans <dev@uxf.cz>",
@@ -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
- const compiled = (0, path_to_regexp_1.compile)(`/${parsedHttpSource.domain}/${parsedHttpSource.path}`, {})(repairedParams);
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
- const compiled = compile(`/${parsedHttpSource.domain}/${parsedHttpSource.path}`, {})(repairedParams);
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",