Subversion Repositories Kolibri OS

Rev

Rev 7755 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. :dword GetAbsoluteURL(dword new_URL, base_URL)
  3. {
  4.         int i;
  5.         dword orig_URL = new_URL;
  6.         char newurl[URL_SIZE+1];
  7.         strcpy(#newurl, base_URL);
  8.  
  9.         while (i=strstr(new_URL, "&"))
  10.         {
  11.                 strcpy(i+1, i+5);
  12.         }
  13.  
  14.         if (check_is_the_url_absolute(new_URL)) return orig_URL;
  15.  
  16.         IF (!strncmp(new_URL,"//", 2))
  17.         {
  18.                 strcpy(#newurl, "http:");
  19.                 strcat(#newurl, new_URL);
  20.                 strcpy(orig_URL, #newurl);
  21.                 return orig_URL;
  22.         }
  23.        
  24.         IF (!strncmp(new_URL,"./", 2)) new_URL+=2;
  25.  
  26.         if (ESBYTE[new_URL] == '/') //remove everything after site domain name
  27.         {
  28.                 i = strchr(#newurl+8, '/');
  29.                 if (i) ESBYTE[i]=0;
  30.                 new_URL+=1;
  31.         }
  32.                
  33.         _CUT_ST_LEVEL_MARK:
  34.                
  35.         if (newurl[strrchr(#newurl, '/')-2]<>'/')
  36.         {
  37.                 newurl[strrchr(#newurl, '/')] = 0x00;
  38.         }
  39.        
  40.         IF (!strncmp(new_URL,"../",3))
  41.         {
  42.                 new_URL+=3;
  43.                 newurl[strrchr(#newurl, '/')-1] = 0x00;
  44.                 goto _CUT_ST_LEVEL_MARK;
  45.         }
  46.        
  47.         if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
  48.        
  49.         strcat(#newurl, new_URL);
  50.         strcpy(orig_URL, #newurl);
  51.         return orig_URL;
  52. }
  53.  
  54.