Skip to content

Commit

Permalink
feat: replace backslashes in _processFile
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Apr 7, 2024
1 parent 67ba3e6 commit 12dceeb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ class Box extends EventEmitter {
if (!params) return count;

const file = new File({
// source is used for filesystem path, keep backslashes on Windows
source: join(base, path),
path,
// path is used for URL path, replace backslashes on Windows
path: path.replace(/\\/g, '/'),
params,
type
});
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/tag/asset_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export = (ctx: Hexo) => {
const attrTitle = escapeHTML(title);
if (escape === 'true') title = attrTitle;

const link = url_for.call(ctx, asset.path.replace(/\\/g, '/'));
const link = url_for.call(ctx, asset.path);

return `<a href="${link}" title="${attrTitle}">${title}</a>`;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/tag/asset_path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export = (ctx: Hexo) => {
const asset = PostAsset.findOne({post: this._id, slug});
if (!asset) return;

const path = url_for.call(ctx, asset.path.replace(/\\/g, '/'));
const path = url_for.call(ctx, asset.path);

return path;
};
Expand Down

0 comments on commit 12dceeb

Please sign in to comment.