Skip to content

Commit 9425de9

Browse files
committed
Use universal-url to get isomorphic URL
1 parent 01e48cb commit 9425de9

File tree

5 files changed

+235
-6
lines changed

5 files changed

+235
-6
lines changed

package-lock.json

+215-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
"type": "git",
1111
"url": "https://github.com/jsonhero-io/json-infer-types.git"
1212
},
13-
"exports": "./lib/index.js",
1413
"types": "lib/index.d.ts",
1514
"main": "./lib/index.js",
16-
"type": "commonjs",
1715
"module": "./lib/index.mjs",
1816
"files": [
1917
"/lib"
@@ -65,6 +63,7 @@
6563
"prettier": "^2.5.1",
6664
"rimraf": "^3.0.2",
6765
"rollup": "^2.62.0",
66+
"rollup-plugin-polyfill-node": "^0.8.0",
6867
"rollup-plugin-typescript2": "^0.31.1",
6968
"ts-jest": "^27.0.7",
7069
"ts-node": "^10.4.0",
@@ -74,6 +73,7 @@
7473
"ip-address": "^8.1.0",
7574
"json5": "^2.2.0",
7675
"mime-types": "^2.1.34",
76+
"universal-url": "^2.0.0",
7777
"uuid": "^8.3.2"
7878
},
7979
"jest": {

src/formats/uri.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { URL } from "url";
1+
import { URL } from "universal-url";
22
import mime from "mime-types";
33
import path from "path";
44

src/universal-url.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module "universal-url" {
2+
export class URL {
3+
constructor(url: string);
4+
pathname: string;
5+
}
6+
}

tests/bugs.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { inferType } from "../src";
2+
3+
test("https://www.mattaitken.com is a string with format of uri", () => {
4+
expect(inferType("https://www.mattaitken.com")).toEqual({
5+
name: "string",
6+
value: "https://www.mattaitken.com",
7+
format: {
8+
name: "uri",
9+
},
10+
});
11+
});

0 commit comments

Comments
 (0)