@doolehealth/service-lib 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -178,16 +178,20 @@ class ApiEndpointsService {
178
178
  //private constants: Constants,
179
179
  endpoints) {
180
180
  this.endpoints = endpoints;
181
- this.getEndpoint = (action) => this.createUrl(action, false);
182
- this.getDooleEndpoint = (action) => this.createUrl(action, true);
181
+ this.getEndpoint = (action) => this.createUrl(action);
182
+ this.getEndpointNoApi = (action) => this.createUrlNoAPI(action);
183
183
  this.getEndpointWithParameters = (action, parameters) => this.createUrlWithQueryParameters(action, parameters);
184
184
  }
185
185
  /* #region URL CREATOR */
186
186
  // URL
187
- createUrl(action, isDooleAPI = false) {
187
+ createUrl(action) {
188
188
  const urlBuilder = new UrlBuilder(this.endpoints.API_ENDPOINT, action);
189
189
  return urlBuilder.toString();
190
190
  }
191
+ createUrlNoAPI(action) {
192
+ const urlBuilder = new UrlBuilder(this.endpoints.DOOLE_ENDPOINT, action);
193
+ return urlBuilder.toString();
194
+ }
191
195
  // URL WITH QUERY PARAMS
192
196
  createUrlWithQueryParameters(action, queryStringHandler) {
193
197
  //Change EndPoind
@@ -581,13 +585,13 @@ class AuthenticationService {
581
585
  localStorage.removeItem('login_request_locked_at');
582
586
  }
583
587
  get(endpt) {
584
- const endpoint = this.api.getDooleEndpoint(endpt);
588
+ const endpoint = this.api.getEndpoint(endpt);
585
589
  return this.http.get(endpoint).pipe(map((res) => {
586
590
  return res;
587
591
  }));
588
592
  }
589
593
  post(endpt, items) {
590
- const endpoint = this.api.getDooleEndpoint(endpt);
594
+ const endpoint = this.api.getEndpoint(endpt);
591
595
  return this.http.post(endpoint, items).pipe(map((res) => {
592
596
  return res;
593
597
  }));
@@ -916,6 +920,29 @@ class DooleService {
916
920
  this.alertController = alertController;
917
921
  this.translate = translate;
918
922
  }
923
+ transformYouTubeUrl(url) {
924
+ if (!url)
925
+ return url;
926
+ // Regular expression to match various YouTube URL formats
927
+ const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
928
+ const match = url.match(regExp);
929
+ if (match && match[2].length === 11) {
930
+ const videoId = match[2];
931
+ // Use the proxy solution to avoid Error 153 in iOS Capacitor apps
932
+ return this.api.getEndpointNoApi('youtube') + '?videoId=' + videoId;
933
+ }
934
+ return url;
935
+ }
936
+ replaceYouTubeIframes(html) {
937
+ if (!html)
938
+ return html;
939
+ // Regex to find iframes with YouTube embed URLs
940
+ const iframeRegex = /<iframe[^>]*src="([^"]*youtube\.com\/embed\/([^"?#]+)[^"]*)"[^>]*><\/iframe>/gi;
941
+ return html.replace(iframeRegex, (match, fullUrl, videoId) => {
942
+ const proxyUrl = this.transformYouTubeUrl(fullUrl);
943
+ return match.replace(fullUrl, proxyUrl);
944
+ });
945
+ }
919
946
  uploadFile(image, id) {
920
947
  ////console.log("uploading ", image);
921
948
  const token = localStorage.getItem('token');