Compare commits

..

1 Commits

Author SHA1 Message Date
326c4b5bc0 build: bump vite from 5.4.14 to 5.4.19
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.14 to 5.4.19.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.4.19/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.19/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 5.4.19
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 12:19:19 +00:00
2 changed files with 34 additions and 17 deletions

16
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@tcgdex/sdk",
"version": "2.6.0",
"version": "2.7.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@tcgdex/sdk",
"version": "2.6.0",
"version": "2.7.0",
"license": "MIT",
"dependencies": {
"@cachex/memory": "^1",
@ -10527,9 +10527,9 @@
}
},
"node_modules/vite": {
"version": "5.4.14",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz",
"integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==",
"version": "5.4.19",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz",
"integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -18322,9 +18322,9 @@
}
},
"vite": {
"version": "5.4.14",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz",
"integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==",
"version": "5.4.19",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz",
"integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==",
"dev": true,
"requires": {
"esbuild": "^0.21.3",

View File

@ -326,22 +326,19 @@ export default class TCGdex {
* format the final URL
*/
private getFullURL(
path: Array<string | number>,
url: Array<string | number>,
searchParams?: Array<{ key: string, value: string | number | boolean }>
): string {
// build base path
const url = new URL(`${this.getEndpoint()}/${this.getLang()}`)
// set url path
url.pathname = `${url.pathname}/${path.join('/')}`
// Normalize path
let path = url.map(this.encode).join('/')
// handle the Search Params
for (const param of searchParams ?? []) {
url.searchParams.append(param.key, param.value.toString())
if (searchParams) {
path += '?' + searchParams.map((it) => `${this.encode(it.key)}=${this.encode(it.value)}`).join('&')
}
// return with the endpoint and all the shit
return url.toString()
return `${this.getEndpoint()}/${this.getLang()}/${path}`
}
private async actualFetch<T = object>(path: string): Promise<T | undefined> {
@ -379,6 +376,26 @@ export default class TCGdex {
this.cache.set(path, json, this.cacheTTL)
return json as T
}
/**
* encode a string to be used in an url
* @param str the string to encode to URL
* @returns the encoded string
*/
private encode(str: string | number | boolean): string {
return encodeURI(
str
// Transform numbers to string
.toString()
// replace this special character with an escaped one
.replace('?', '%3F')
// normalize the string
.normalize('NFC')
// remove some special chars
// eslint-disable-next-line no-misleading-character-class
.replace(/["'\u0300-\u036f]/gu, '')
)
}
}
// export the old interfaces