Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/plugins/tag/asset_img.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { resolve } = require('url');
const img = require('./img');
const { encodeURL } = require('hexo-util');

Expand All @@ -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);
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/plugins/tag/asset_link.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const { encodeURL, escapeHTML } = require('hexo-util');
const { resolve } = require('url');

/**
* Asset link tag
Expand Down Expand Up @@ -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 `<a href="${link}" title="${attrTitle}">${title}</a>`;
};
Expand Down
3 changes: 1 addition & 2 deletions lib/plugins/tag/asset_path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { resolve } = require('url');
const { encodeURL } = require('hexo-util');

/**
Expand All @@ -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;
};
Expand Down
3 changes: 1 addition & 2 deletions lib/plugins/tag/post_link.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const { encodeURL, escapeHTML } = require('hexo-util');
const { resolve } = require('url');
const { postFindOneFactory } = require('./');

/**
Expand Down Expand Up @@ -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 `<a href="${link}" title="${attrTitle}">${title}</a>`;
};
Expand Down
3 changes: 1 addition & 2 deletions lib/plugins/tag/post_path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { resolve } = require('url');
const { encodeURL } = require('hexo-util');
const { postFindOneFactory } = require('./');

Expand All @@ -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;
};
Expand Down