Registriert seit: 26. Mai 2004
3.159 Beiträge
|
AW: Base Url aus LocationURL Finden
6. Jan 2012, 20: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)
|
|
Zitat
|