Einzelnen Beitrag anzeigen

Benutzerbild von s.h.a.r.k
s.h.a.r.k

Registriert seit: 26. Mai 2004
3.159 Beiträge
 
#2

AW: Base Url aus LocationURL Finden

  Alt 6. Jan 2012, 19:23
Delphi-Quellcode:
function ExtractBaseUrlFromGeneralUrl(Url: string): string;
var
  Index : Integer;
  Protocol : string;
  PathExists : Boolean;
begin
  // if (not IsValidUrl(Url)) then
  // raise Exception.Create(...);

  // Remove http://, https://, ftp://
  Index := Pos('://', Url);
  Protocol := Copy(Url, 1, Index + 2);
  Writeln(Protocol);
  Delete(Url, 1, Index + 2);

  // Remove path if there is any at the and of the url
  Index := Pos('/', Url);
  PathExists := (Index > 0);
  if (PathExists) then
    Delete(Url, Index, Length(Url));

  Result := Protocol + Url;
end;
Nun eine korrekte Version... Hatte das Protokoll vergessen...
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
  Mit Zitat antworten Zitat