diff --git a/lib/plugins/tag/asset_img.js b/lib/plugins/tag/asset_img.js
index df1b67bd34..5189c28a27 100644
--- a/lib/plugins/tag/asset_img.js
+++ b/lib/plugins/tag/asset_img.js
@@ -1,6 +1,5 @@
'use strict';
-const { resolve } = require('url');
const img = require('./img');
const { encodeURL } = require('hexo-util');
@@ -20,7 +19,7 @@ module.exports = ctx => {
for (let i = 0; i < len; i++) {
const asset = PostAsset.findOne({post: this._id, slug: args[i]});
if (asset) {
- args[i] = encodeURL(resolve('/', asset.path));
+ args[i] = encodeURL(new URL(asset.path, ctx.config.url).pathname);
return img(ctx)(args);
}
}
diff --git a/lib/plugins/tag/asset_link.js b/lib/plugins/tag/asset_link.js
index c51dc3e005..8f3225e297 100644
--- a/lib/plugins/tag/asset_link.js
+++ b/lib/plugins/tag/asset_link.js
@@ -1,7 +1,6 @@
'use strict';
const { encodeURL, escapeHTML } = require('hexo-util');
-const { resolve } = require('url');
/**
* Asset link tag
@@ -30,7 +29,7 @@ module.exports = ctx => {
const attrTitle = escapeHTML(title);
if (escape === 'true') title = attrTitle;
- const link = encodeURL(resolve(ctx.config.root, asset.path));
+ const link = encodeURL(new URL(asset.path, ctx.config.url).pathname);
return `${title}`;
};
diff --git a/lib/plugins/tag/asset_path.js b/lib/plugins/tag/asset_path.js
index 88be887673..d988176d30 100644
--- a/lib/plugins/tag/asset_path.js
+++ b/lib/plugins/tag/asset_path.js
@@ -1,6 +1,5 @@
'use strict';
-const { resolve } = require('url');
const { encodeURL } = require('hexo-util');
/**
@@ -19,7 +18,7 @@ module.exports = ctx => {
const asset = PostAsset.findOne({post: this._id, slug});
if (!asset) return;
- const path = encodeURL(resolve(ctx.config.root, asset.path));
+ const path = encodeURL(new URL(asset.path, ctx.config.url).pathname);
return path;
};
diff --git a/lib/plugins/tag/post_link.js b/lib/plugins/tag/post_link.js
index 553e7599ce..838b046560 100644
--- a/lib/plugins/tag/post_link.js
+++ b/lib/plugins/tag/post_link.js
@@ -1,7 +1,6 @@
'use strict';
const { encodeURL, escapeHTML } = require('hexo-util');
-const { resolve } = require('url');
const { postFindOneFactory } = require('./');
/**
@@ -35,7 +34,7 @@ module.exports = ctx => {
const attrTitle = escapeHTML(post.title);
if (escape === 'true') title = escapeHTML(title);
- const link = encodeURL(resolve(ctx.config.root, post.path));
+ const link = encodeURL(new URL(post.path, ctx.config.url).pathname);
return `${title}`;
};
diff --git a/lib/plugins/tag/post_path.js b/lib/plugins/tag/post_path.js
index 89346560f4..679f65039f 100644
--- a/lib/plugins/tag/post_path.js
+++ b/lib/plugins/tag/post_path.js
@@ -1,6 +1,5 @@
'use strict';
-const { resolve } = require('url');
const { encodeURL } = require('hexo-util');
const { postFindOneFactory } = require('./');
@@ -19,7 +18,7 @@ module.exports = ctx => {
const post = factory({ slug }) || factory({ title: slug });
if (!post) return;
- const link = encodeURL(resolve(ctx.config.root, post.path));
+ const link = encodeURL(new URL(post.path, ctx.config.url).pathname);
return link;
};