我试图将两个URL组合到一个URL中。
let url = "http://example.com/public/";
我在path "/samples/leads/Import_Leads_Sample.csv"
中有来自API的文件。我将其作为一个下标,因为filepath
现在FilePath持有
filepath: "/samples/leads/Import_Leads_Sample.csv"
我希望将其组合在一起并形成一个URL为。
let url = "http://example.com/public/samples/leads/Import_Leads_Sample.csv"
将filepath存储在变量中并组合两个变量。
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