Changeset 230 for Common/UURI.pas
- Timestamp:
- Apr 14, 2011, 12:45:52 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/UURI.pas
r226 r230 9 9 uses 10 10 Classes, SysUtils; 11 12 const 13 URIPathSeparator = '/'; 11 14 12 15 type … … 21 24 Items: TStringList; 22 25 IsAbsolute: Boolean; 26 DirSeparator: string; 23 27 procedure Assign(Source: TPath); 24 28 constructor Create; … … 137 141 I: Integer; 138 142 begin 139 if IsAbsolute then Result := Dir ectorySeparator143 if IsAbsolute then Result := DirSeparator 140 144 else Result := ''; 141 145 for I := 0 to Items.Count - 1 do 142 Result := Result + Items[I] + Dir ectorySeparator;146 Result := Result + Items[I] + DirSeparator; 143 147 end; 144 148 … … 149 153 Items.Clear; 150 154 if Length(AValue) > 0 then begin 151 if AValue[1] = Dir ectorySeparator then begin155 if AValue[1] = DirSeparator then begin 152 156 IsAbsolute := True; 153 157 Delete(AValue, 1, 1); 154 158 end else IsAbsolute := False; 155 while Pos(Dir ectorySeparator, AValue) > 0 do begin156 Name := Copy(AValue, 1, Pos(Dir ectorySeparator, AValue) - 1);157 Delete(AValue, 1, Pos(Dir ectorySeparator, AValue));159 while Pos(DirSeparator, AValue) > 0 do begin 160 Name := Copy(AValue, 1, Pos(DirSeparator, AValue) - 1); 161 Delete(AValue, 1, Pos(DirSeparator, AValue)); 158 162 Items.Add(Name); 159 163 end; … … 167 171 IsAbsolute := Source.IsAbsolute; 168 172 Items.Assign(Source.Items); 173 DirSeparator := Source.DirSeparator; 169 174 end; 170 175 … … 172 177 begin 173 178 Items := TStringList.Create; 179 DirSeparator := DirectorySeparator; 174 180 end; 175 181 … … 188 194 if Path.Combine <> '' then begin 189 195 Result := Result + '//' + Authority; 190 if Path.Drive <> '' then Result := Result + '/';196 if Scheme = 'file' then Result := Result + URIPathSeparator; 191 197 Result := Result + Path.Combine; 192 198 end; 193 199 if Query <> '' then Result := Result + '?' + Query; 194 200 if Fragment <> '' then Result := Result + '#' + Fragment; 195 StringReplace(Result, '\', '/', [rfReplaceAll]);196 201 end; 197 202 … … 204 209 if Copy(Value, 1, 2) = '//' then begin 205 210 Value := Copy(Value, 3, Length(Value)); 206 LeftCutString(Value, Authority, '/');211 LeftCutString(Value, Authority, URIPathSeparator); 207 212 end; 208 213 RightCutString(Value, Fragment, '#'); 209 214 RightCutString(Value, Query, '?', '=&'); 210 if (Length(Value) > 2) and (Value[2] = DriveSeparator) then 211 Delete(Value, 1, 1); // Remove beginning slash 215 //if Scheme = 'file' then Delete(Value, 1, 1); // Remove beginning slash 212 216 Path.Parse(Value); 213 217 end; … … 216 220 begin 217 221 Path := TFileName.Create; 222 Path.Directory.DirSeparator := URIPathSeparator; 218 223 end; 219 224 … … 278 283 end else LeftCutString(Value, HostAddr, '', '.'); 279 284 Host := HostAddr; 280 LeftCutString(Value, TempPath, '', '/.');285 LeftCutString(Value, TempPath, '', URIPathSeparator + '.'); 281 286 Path.Parse(TempPath); 282 287 end; … … 311 316 Extension := ExtensionSeparator + Extension; 312 317 end else Extension := ''; 313 if Pos(DirectorySeparator, AValue) > 0 then RightCutString(AValue, Name, DirectorySeparator) 318 if Pos(Directory.DirSeparator, AValue) > 0 then 319 RightCutString(AValue, Name, Directory.DirSeparator) 314 320 else begin 315 321 Name := AValue;
Note:
See TracChangeset
for help on using the changeset viewer.