Nodejs file path to url path

时间:2021-01-12 10:31:13   收藏:0   阅读:0
import * as path from ‘path‘;
import * as url from ‘url‘;

const savePath = path.join(‘public‘, ‘images‘, ‘a.jpg‘); 
// => \public\images\a.jpg

const urlPath = url.parse(savePath).path; 
// => /public/images/a.jpg
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!