fix: feature request 2106 (Always use forward slashes on Windows) (#2824)

This commit is contained in:
Kiyoka Nishiyama 2021-12-30 11:11:46 +00:00 committed by GitHub
parent db1d2b7aef
commit 93da27118d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import dayjs from 'dayjs'
import Octokit from '@octokit/rest'
import { ensureDirSync } from 'common/filesystem'
import { isImageFile } from 'common/filesystem/paths'
import { dataURItoBlob } from './index'
import { isWindows, dataURItoBlob } from './index'
import axios from '../axios'
export const create = (pathname, type) => {
@ -51,6 +51,11 @@ export const moveToRelativeFolder = async (cwd, imagePath, relativeName) => {
// dstRelPath: relative directory name + image file name
const dstRelPath = path.join(relativeName, path.basename(imagePath))
if (isWindows) {
// Use forward slashes for better compatibility with websites.
return dstRelPath.replace(/\\/g, '/')
}
return dstRelPath
}