Skip to content

Commit a6ea1af

Browse files
authored
Modernized for not requiring URIJS anymore => reduces effect on bundle size
Removes URIJS polyfill. This is natively supported by most browsers/environments today and reduces bundle size dramatically when using this library. Switches to url-template for templating needs.
1 parent 863b47e commit a6ea1af

File tree

6 files changed

+222
-219
lines changed

6 files changed

+222
-219
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: npm version --no-git-tag-version ${{steps.gitversion.outputs.nuGetVersion}}
2121

2222
# Build
23-
- run: npm install
23+
- run: npm ci
2424
- run: npm run build
2525
- run: npm run test
2626
- run: npm run docs

endpoints/Endpoint.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import template from 'url-template';
12
import { HttpMethod, HttpHeader, HttpClient } from "../http";
23
import { Serializer } from "../serializers";
34
import { ErrorHandler, NotFoundError } from "../errors";
45
import { LinkExtractor, Link } from "../links";
5-
import URI from "urijs";
6-
import "urijs/src/URITemplate";
76

87
export class Endpoint {
98
/**
@@ -201,7 +200,8 @@ export class Endpoint {
201200
* @throws {@link errors!NotFoundError}: No link template with the specified `rel` could be found.
202201
*/
203202
linkTemplate(rel: string, variables: { [key: string]: any; }): URL {
204-
return this.join(URI.expand!(this.getLinkTemplate(rel), variables).toString());
203+
const tmpl = template.parse(this.getLinkTemplate(rel))
204+
return new URL(this.join(tmpl.expand(variables)))
205205
}
206206

207207
/**

jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
// jsdom is required for Blob() constructor and fetch()!
5+
testEnvironment: 'jsdom',
6+
testMatch: [
7+
"**/?(*.)+(spec|test).ts"
8+
],
9+
transform: {
10+
"\\.ts$": "ts-jest"
11+
},
12+
};

0 commit comments

Comments
 (0)