我正在尝试将两个网址合并为一个网址。
let url = "http://example.com/public/";
我在路径"/samples/leads/Import_Leads_Sample.csv"
中有来自 API 的文件。我把它放在一个下标中,因为filepath
现在文件路径包含
filepath: "/samples/leads/Import_Leads_Sample.csv"
我希望将这两者结合起来并形成一个 URL。
let url = "http://example.com/public/samples/leads/Import_Leads_Sample.csv"
将文件路径存储在一个变量中并组合两个变量。
let url = "http://example.com/public/";
let filepath = Object.filepath; // equals "/samples/leads/Import_Leads_Sample.csv"
let finalUrl = url + filepath.substr(1); // substr(1) to remove the '/' and avoid having a final url with '//' in it
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句