(audioUrl, trackingUrls, protocal='https')
| 141 | } |
| 142 | |
| 143 | export function buildAudioUrlWithTracking(audioUrl, trackingUrls, protocal='https') { |
| 144 | if (!audioUrl) { |
| 145 | return ''; |
| 146 | } |
| 147 | if (!trackingUrls || trackingUrls.length === 0) { |
| 148 | return audioUrl; |
| 149 | } |
| 150 | |
| 151 | try { |
| 152 | const protocalRegex = /^https?:\/\//; |
| 153 | const audioUrlNoProtocal = audioUrl.replace(protocalRegex, ''); |
| 154 | const trackingUrlsNoProtocal = trackingUrls.map(u => u.replace(protocalRegex, '')); |
| 155 | let finalUrl = `${protocal}://${trackingUrlsNoProtocal[0]}`; |
| 156 | trackingUrlsNoProtocal.shift(); |
| 157 | return urlJoin(finalUrl, ...trackingUrlsNoProtocal, audioUrlNoProtocal); |
| 158 | // trackingUrlsNoProtocal.forEach((u) => { |
| 159 | // const obj = new URL(u, finalUrl); |
| 160 | // finalUrl = obj.href; |
| 161 | // }); |
| 162 | // const finalUrlObj = new URL(audioUrlNoProtocal, finalUrl); |
| 163 | // return finalUrlObj.href; |
| 164 | } catch(e) { |
| 165 | return audioUrl; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | export function getIdFromSlug(slug) { |
| 170 | let itemId |
no test coverage detected