@hzab/data-model 1.7.6 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/public-utils.js +7 -5
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/public-utils.js
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
* @param {*} url 文件路径
|
|
4
4
|
* @param {*} opt
|
|
5
5
|
*/
|
|
6
|
-
export function getPublicUrl(url, opt) {
|
|
6
|
+
export function getPublicUrl(url, opt = {}) {
|
|
7
7
|
if (typeof url !== "string") {
|
|
8
8
|
return url;
|
|
9
9
|
}
|
|
10
|
+
const { isFullPath } = opt || {};
|
|
10
11
|
let baseURL = (process.env.WEBPACK_PUBLIC_PATH || ".")?.replace(/^\//, "")?.replace(/\/$/, "");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
""
|
|
14
|
-
|
|
12
|
+
if (isFullPath) {
|
|
13
|
+
const fullPathname = (location.origin + location.pathname).replace(/[^\/]+.html\/?$/, "").replace(/\/$/, "");
|
|
14
|
+
return `${fullPathname}/${baseURL?.replace(/^\./, "")}/${url?.replace(/^\//, "")}`;
|
|
15
|
+
}
|
|
16
|
+
return `${baseURL}/${url?.replace(/^\//, "")}`;
|
|
15
17
|
}
|