@pixi/utils
Advanced tools
Comparing version 7.3.0-rc.2 to 7.3.0
@@ -6,2 +6,3 @@ export interface Path { | ||
isDataUrl: (path: string) => boolean; | ||
isBlobUrl: (path: string) => boolean; | ||
hasProtocol: (path: string) => boolean; | ||
@@ -8,0 +9,0 @@ getProtocol: (path: string) => string; |
@@ -59,3 +59,3 @@ "use strict"; | ||
/** | ||
* Checks if the path is a URL | ||
* Checks if the path is a URL e.g. http://, https:// | ||
* @param path - The path to check | ||
@@ -74,3 +74,10 @@ */ | ||
/** | ||
* Checks if the path has a protocol e.g. http:// | ||
* Checks if the path is a blob URL | ||
* @param path - The path to check | ||
*/ | ||
isBlobUrl(path2) { | ||
return path2.startsWith("blob:"); | ||
}, | ||
/** | ||
* Checks if the path has a protocol e.g. http://, https://, file:///, data:, blob:, C:/ | ||
* This will return true for windows file paths | ||
@@ -80,6 +87,6 @@ * @param path - The path to check | ||
hasProtocol(path2) { | ||
return /^[^/:]+:\//.test(this.toPosix(path2)); | ||
return /^[^/:]+:/.test(this.toPosix(path2)); | ||
}, | ||
/** | ||
* Returns the protocol of the path e.g. http://, C:/, file:/// | ||
* Returns the protocol of the path e.g. http://, https://, file:///, data:, blob:, C:/ | ||
* @param path - The path to get the protocol from | ||
@@ -89,9 +96,7 @@ */ | ||
assertPath(path2), path2 = this.toPosix(path2); | ||
let protocol = ""; | ||
const isFile = /^file:\/\/\//.exec(path2), isHttp = /^[^/:]+:\/\//.exec(path2), isWindows = /^[^/:]+:\//.exec(path2); | ||
if (isFile || isHttp || isWindows) { | ||
const arr = isFile?.[0] || isHttp?.[0] || isWindows?.[0]; | ||
protocol = arr, path2 = path2.slice(arr.length); | ||
} | ||
return protocol; | ||
const matchFile = /^file:\/\/\//.exec(path2); | ||
if (matchFile) | ||
return matchFile[0]; | ||
const matchProtocol = /^[^/:]+:\/{0,2}/.exec(path2); | ||
return matchProtocol ? matchProtocol[0] : ""; | ||
}, | ||
@@ -108,6 +113,6 @@ /** | ||
toAbsolute(url, customBaseUrl, customRootUrl) { | ||
if (this.isDataUrl(url)) | ||
if (assertPath(url), this.isDataUrl(url) || this.isBlobUrl(url)) | ||
return url; | ||
const baseUrl = removeUrlParams(this.toPosix(customBaseUrl ?? settings.settings.ADAPTER.getBaseUrl())), rootUrl = removeUrlParams(this.toPosix(customRootUrl ?? this.rootname(baseUrl))); | ||
return assertPath(url), url = this.toPosix(url), url.startsWith("/") ? path.join(rootUrl, url.slice(1)) : this.isAbsolute(url) ? url : this.join(baseUrl, url); | ||
return url = this.toPosix(url), url.startsWith("/") ? path.join(rootUrl, url.slice(1)) : this.isAbsolute(url) ? url : this.join(baseUrl, url); | ||
}, | ||
@@ -119,4 +124,7 @@ /** | ||
normalize(path2) { | ||
if (path2 = this.toPosix(path2), assertPath(path2), path2.length === 0) | ||
if (assertPath(path2), path2.length === 0) | ||
return "."; | ||
if (this.isDataUrl(path2) || this.isBlobUrl(path2)) | ||
return path2; | ||
path2 = this.toPosix(path2); | ||
let protocol = ""; | ||
@@ -123,0 +131,0 @@ const isAbsolute = path2.startsWith("/"); |
{ | ||
"name": "@pixi/utils", | ||
"version": "7.3.0-rc.2", | ||
"version": "7.3.0", | ||
"main": "lib/index.js", | ||
@@ -39,5 +39,5 @@ "module": "lib/index.mjs", | ||
"dependencies": { | ||
"@pixi/color": "7.3.0-rc.2", | ||
"@pixi/constants": "7.3.0-rc.2", | ||
"@pixi/settings": "7.3.0-rc.2", | ||
"@pixi/color": "7.3.0", | ||
"@pixi/constants": "7.3.0", | ||
"@pixi/settings": "7.3.0", | ||
"@types/earcut": "^2.1.0", | ||
@@ -44,0 +44,0 @@ "earcut": "^2.2.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
248893
2312
0
+ Added@pixi/color@7.3.0(transitive)
+ Added@pixi/constants@7.3.0(transitive)
+ Added@pixi/settings@7.3.0(transitive)
- Removed@pixi/color@7.3.0-rc.2(transitive)
- Removed@pixi/constants@7.3.0-rc.2(transitive)
- Removed@pixi/settings@7.3.0-rc.2(transitive)
Updated@pixi/color@7.3.0
Updated@pixi/constants@7.3.0
Updated@pixi/settings@7.3.0