MCPcopy
hub / github.com/microfeed/microfeed / buildAudioUrlWithTracking

Function buildAudioUrlWithTracking

common-src/StringUtils.js:143–167  ·  view source on GitHub ↗
(audioUrl, trackingUrls, protocal='https')

Source from the content-addressed store, hash-verified

141}
142
143export 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
169export function getIdFromSlug(slug) {
170 let itemId

Callers 3

renderMethod · 0.90

Calls 1

urlJoinFunction · 0.85

Tested by

no test coverage detected