[Delphi (Object Pascal)] Delphi判断是否是有效的url协议 →→→→→进入此内容的聊天室

来自 , 2019-05-28, 写在 Delphi (Object Pascal), 查看 142 次.
URL http://www.code666.cn/view/a523426c
  1. function IsValidURLProtocol(const URL: string): Boolean;
  2. const
  3.   Protocols: array[1..10] of string = (
  4.     // Array of valid protocols - per RFC 1738
  5.     'ftp://', 'http://', 'gopher://', 'mailto:', 'news:', 'nntp://',
  6.     'telnet://', 'wais://', 'file://', 'prospero://'
  7.   );
  8. var
  9.   I: Integer;   // loops thru known protocols
  10. begin
  11.   // Scan array of protocols checking for a match with start of given URL
  12.   Result := False;
  13.   for I := Low(Protocols) to High(Protocols) do
  14.     if Pos(Protocols[I], SysUtils.LowerCase(URL)) = 1 then
  15.     begin
  16.       Result := True;
  17.       Exit;
  18.     end;
  19. end;
  20. //delphi/2263

回复 "Delphi判断是否是有效的url协议"

这儿你可以回复上面这条便签

captcha