Nodejs file path to url path

import * as path from 'path';
import * as url from 'url';

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

const urlPath = url.parse(savePath).path; 
// => /public/images/a.jpg
原文地址:https://www.cnblogs.com/ajanuw/p/14254432.html