Url_Manipulation.dpr 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. program Url_Manipulation;
  2. {$APPTYPE CONSOLE}
  3. {$R *.res}
  4. uses
  5. System.SysUtils,
  6. Quick.Commons,
  7. Quick.Console;
  8. const
  9. aurls : array[0..4] of string = ('https://mydomain.com',
  10. 'http://www.google.com/Test/other',
  11. 'www.google.com/test/other?query=1&other=2',
  12. 'http://127.0.0.1:80/onemoretest/',
  13. 'www.google.com');
  14. var
  15. i : Integer;
  16. host : string;
  17. path : string;
  18. query : string;
  19. woquery : string;
  20. begin
  21. try
  22. for i := Low(aurls) to High(aurls) do
  23. begin
  24. cout('URL="%s"',[aurls[i]],etWarning);
  25. host := UrlGetHost(aurls[i]);
  26. path := UrlGetPath(aurls[i]);
  27. query := UrlGetQuery(aurls[i]);
  28. woquery := UrlRemovequery(aurls[i]);
  29. cout('Host="%s"',[host],etInfo);
  30. cout('Path="%s"',[path],etInfo);
  31. cout('Query="%s"',[query],etInfo);
  32. cout('Without query="%s"',[woquery],etInfo);
  33. cout('------------',etWarning);
  34. end;
  35. ConsoleWaitForEnterKey;
  36. except
  37. on E: Exception do
  38. Writeln(E.ClassName, ': ', E.Message);
  39. end;
  40. end.