Skip to content

Commit 80c014f

Browse files
authored
Revert "Revert fast-uri change (#2444)" (#2448)
* Revert "Revert fast-uri change (#2444)" This reverts commit c8b37f4. * fix inports * up
1 parent c8b37f4 commit 80c014f

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

docs/options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Include human-readable messages in errors. `true` by default. `false` can be pas
344344

345345
### uriResolver
346346

347-
By default `uriResolver` is undefined and relies on the embedded uriResolver [uri-js](https://github.com/garycourt/uri-js). Pass an object that satisfies the interface [UriResolver](https://github.com/ajv-validator/ajv/blob/master/lib/types/index.ts) to be used in replacement. One alternative is [fast-uri](https://github.com/fastify/fast-uri).
347+
By default `uriResolver` is undefined and relies on the embedded uriResolver [fast-uri](https://github.com/fastify/fast-uri). Pass an object that satisfies the interface [UriResolver](https://github.com/ajv-validator/ajv/blob/master/lib/types/index.ts) to be used in replacement. One alternative is [uri-js](https://github.com/garycourt/uri-js).
348348

349349
### code <Badge text="v7" />
350350

lib/compile/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import N from "./names"
1414
import {LocalRefs, getFullPath, _getFullPath, inlineRef, normalizeId, resolveUrl} from "./resolve"
1515
import {schemaHasRulesButRef, unescapeFragment} from "./util"
1616
import {validateFunctionCode} from "./validate"
17-
import * as URI from "uri-js"
17+
import {URIComponent} from "fast-uri"
1818
import {JSONType} from "./rules"
1919

2020
export type SchemaRefs = {
@@ -295,7 +295,7 @@ const PREVENT_SCOPE_CHANGE = new Set([
295295

296296
function getJsonPointer(
297297
this: Ajv,
298-
parsedRef: URI.URIComponents,
298+
parsedRef: URIComponent,
299299
{baseId, schema, root}: SchemaEnv
300300
): SchemaEnv | undefined {
301301
if (parsedRef.fragment?.[0] !== "/") return

lib/compile/resolve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {AnySchema, AnySchemaObject, UriResolver} from "../types"
22
import type Ajv from "../ajv"
3-
import type {URIComponents} from "uri-js"
3+
import type {URIComponent} from "fast-uri"
44
import {eachItem} from "./util"
55
import * as equal from "fast-deep-equal"
66
import * as traverse from "json-schema-traverse"
@@ -73,7 +73,7 @@ export function getFullPath(resolver: UriResolver, id = "", normalize?: boolean)
7373
return _getFullPath(resolver, p)
7474
}
7575

76-
export function _getFullPath(resolver: UriResolver, p: URIComponents): string {
76+
export function _getFullPath(resolver: UriResolver, p: URIComponent): string {
7777
const serialized = resolver.serialize(p)
7878
return serialized.split("#")[0] + "#"
7979
}

lib/runtime/uri.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as uri from "uri-js"
1+
import * as uri from "fast-uri"
22

33
type URI = typeof uri & {code: string}
44
;(uri as URI).code = 'require("ajv/dist/runtime/uri").default'

lib/types/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as URI from "uri-js"
1+
import {URIComponent} from "fast-uri"
22
import type {CodeGen, Code, Name, ScopeValueSets, ValueScopeName} from "../compile/codegen"
33
import type {SchemaEnv, SchemaCxt, SchemaObjCxt} from "../compile"
44
import type {JSONType} from "../compile/rules"
@@ -238,7 +238,7 @@ export interface RegExpLike {
238238
}
239239

240240
export interface UriResolver {
241-
parse(uri: string): URI.URIComponents
241+
parse(uri: string): URIComponent
242242
resolve(base: string, path: string): string
243-
serialize(component: URI.URIComponents): string
243+
serialize(component: URIComponent): string
244244
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
"runkitExampleFilename": ".runkit_example.js",
6060
"dependencies": {
6161
"fast-deep-equal": "^3.1.3",
62+
"fast-uri": "^2.4.0",
6263
"json-schema-traverse": "^1.0.0",
63-
"require-from-string": "^2.0.2",
64-
"uri-js": "^4.4.1"
64+
"require-from-string": "^2.0.2"
6565
},
6666
"devDependencies": {
6767
"@ajv-validator/config": "^0.5.0",
@@ -83,7 +83,6 @@
8383
"dayjs-plugin-utc": "^0.1.2",
8484
"eslint": "^8.57.0",
8585
"eslint-config-prettier": "^9.1.0",
86-
"fast-uri": "^2.3.0",
8786
"glob": "^10.3.10",
8887
"husky": "^9.0.11",
8988
"if-node-version": "^1.1.1",
@@ -104,7 +103,8 @@
104103
"rollup-plugin-terser": "^7.0.2",
105104
"ts-node": "^10.9.2",
106105
"tsify": "^5.0.4",
107-
"typescript": "5.3.3"
106+
"typescript": "5.3.3",
107+
"uri-js": "^4.4.1"
108108
},
109109
"collective": {
110110
"type": "opencollective",

spec/resolve.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import _Ajv from "./ajv"
44
import type {AnyValidateFunction} from "../dist/types"
55
import type MissingRefError from "../dist/compile/ref_error"
66
import chai from "./chai"
7-
import * as fastUri from "fast-uri"
7+
import * as uriJs from "uri-js"
88
const should = chai.should()
99

10-
const uriResolvers = [undefined, fastUri]
10+
const uriResolvers = [undefined, uriJs]
1111

1212
uriResolvers.forEach((resolver) => {
1313
let describeTitle: string
1414
if (resolver !== undefined) {
15-
describeTitle = "fast-uri resolver"
16-
} else {
1715
describeTitle = "uri-js resolver"
16+
} else {
17+
describeTitle = "fast-uri resolver"
1818
}
1919
describe(describeTitle, () => {
2020
describe("resolve", () => {

0 commit comments

Comments
 (0)