Nodejs file path to url path

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
posted @ 2021-01-09 11:23  Ajanuw  阅读(169)  评论(0编辑  收藏  举报