delphi - 将 URL 修剪为根

标签 delphi

如何在 Delphi 中完成此操作?例如..

网址 = https://mail.google.com/mail/u/0/?tab=wm#inbox

修剪后的网址 = https://mail.google.com/

谢谢

最佳答案

使用 Indy 的 TIdURI 的示例代码可能是:

uses
  IdURI;

function GetProtoAndHost(const URI: string): string;
var
  IdURI: TIdURI;
begin
  IdURI := TIdURI.Create(URI);
  try
    Result := IdURI.Protocol + '://' + IdURI.Host + '/';
  finally
    IdURI.Free;
  end;
end;

关于delphi - 将 URL 修剪为根,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13259073/

相关文章:

delphi - Result 变量是从函数的第一行定义的吗?

windows - Delphi 10.1 - Windows 10 Creators Update 后日期时间选择器出现问题

delphi - 确定哪个帮助上下文 ID 正在发送到帮助文件?

multithreading - 这是在 Delphi 6 中设置线程名称的正确方法吗?

Delphi - 我如何告诉系统使用哪台打印机?

delphi - 打印机打印尺寸

delphi - 需要获取套接字描述符

delphi - 如何在Delphi组件中存储大文本?

delphi - Coderush%?SysDate()%日期格式

delphi - 如何在 TStringList 对象中存储集合?