Lines Matching +full:path +full:- +full:is +full:- +full:absolute
2 // Use of this source code is governed by a BSD-style license that can be
25 // Firefox does a case-sensitive compare (which is probably wrong--Mozilla bug
26 // 379034), whereas IE is case-insensitive.
42 // We assume the base is already canonical, so we don't have to in AreSchemesEqual()
54 // consistent about URL paths beginning with slashes. This function is like
70 // Caller should ensure that the |scheme| is not empty. in IsValidScheme()
73 // From https://url.spec.whatwg.org/#scheme-start-state: in IsValidScheme()
75 // 1. If c is an ASCII alpha, append c, lowercased, to buffer, and set in IsValidScheme()
77 // 2. Otherwise, if state override is not given, set state to no scheme in IsValidScheme()
84 // From https://url.spec.whatwg.org/#scheme-state: in IsValidScheme()
86 // 1. If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E in IsValidScheme()
88 // 2. Otherwise, if c is U+003A (:), then [...] in IsValidScheme()
132 // We treat "C:/foo" as an absolute URL. We can go ahead and treat "/c:/" in DoIsRelativeURL()
133 // as relative, as this will just replace the path when the base scheme in DoIsRelativeURL()
134 // is a file and the answer will still be correct. in DoIsRelativeURL()
143 // See if we've got a scheme, if not, we know this is a relative URL. in DoIsRelativeURL()
144 // BUT, just because we have a scheme, doesn't make it absolute. in DoIsRelativeURL()
145 // "http:foo.html" is a relative URL with path "foo.html". If the scheme is in DoIsRelativeURL()
152 // |url| is a bare fragment (e.g. "#foo"). This can be resolved against in DoIsRelativeURL()
153 // any base. Fall-through. in DoIsRelativeURL()
169 // |url| is a bare fragment (e.g. "#foo:bar"). This can be resolved in DoIsRelativeURL()
170 // against any base. Fall-through. in DoIsRelativeURL()
180 // If the scheme is not the same, then we can't count it as relative. in DoIsRelativeURL()
184 // When the scheme that they both share is not hierarchical, treat the in DoIsRelativeURL()
185 // incoming scheme as absolute (this way with the base of "data:foo", in DoIsRelativeURL()
186 // "data:bar" will be reported as absolute. in DoIsRelativeURL()
192 // If it's a filesystem URL, the only valid way to make it relative is not to in DoIsRelativeURL()
199 // case where the begin offset is the end of the input. in DoIsRelativeURL()
203 // No slashes means it's a relative path like "http:foo.html". One slash in DoIsRelativeURL()
204 // is an absolute path. "http:/home/foo.html" in DoIsRelativeURL()
210 // Two or more slashes after the scheme we treat as absolute. in DoIsRelativeURL()
219 // URLs on a non-standard base (like "data:") the input can be anything.
225 int last_slash = -1; in CopyToLastSlash()
226 for (int i = end - 1; i >= begin; i--) { in CopyToLastSlash()
237 output->push_back(spec[i]); in CopyToLastSlash()
240 // Copies a single component from the source to the output. This is used
241 // when resolving relative URLs and a given component is unchanged. Since the
243 // and the input is ASCII.
249 // This component is not present. in CopyOneComponent()
254 output_component->begin = output->length(); in CopyOneComponent()
257 output->push_back(source[i]); in CopyOneComponent()
258 output_component->len = output->length() - output_component->begin; in CopyOneComponent()
263 // Called on Windows when the base URL is a file URL, this will copy the "C:"
264 // to the output, if there is a drive letter and if that drive letter is not
268 // base to be processed: if there is a "C:", the slash after it, or if
269 // there is no drive letter, the slash at the beginning of the path, or
271 // path processing.
281 return base_path_begin; // No path. in CopyBaseDriveSpecIfNecessary()
286 return base_path_begin; // Relative URL path is "C:/foo" in CopyBaseDriveSpecIfNecessary()
289 // The path should begin with a slash (as all canonical paths do). We check in CopyBaseDriveSpecIfNecessary()
290 // if it is followed by a drive letter and copy it. in CopyBaseDriveSpecIfNecessary()
294 // Copy the two-character drive spec to the output. It will now look like in CopyBaseDriveSpecIfNecessary()
295 // "file:///C:" so the rest of it can be treated like a standard path. in CopyBaseDriveSpecIfNecessary()
296 output->push_back('/'); in CopyBaseDriveSpecIfNecessary()
297 output->push_back(base_url[base_path_begin + 1]); in CopyBaseDriveSpecIfNecessary()
298 output->push_back(base_url[base_path_begin + 2]); in CopyBaseDriveSpecIfNecessary()
308 // the input is a relative path or less (query or ref).
321 // also know we have a path so can copy up to there. in DoResolveRelativePath()
322 Component path, query, ref; in DoResolveRelativePath() local
323 ParsePathInternal(relative_url, relative_component, &path, &query, &ref); in DoResolveRelativePath()
325 // Canonical URLs always have a path, so we can use that offset. Reserve in DoResolveRelativePath()
326 // enough room for the base URL, the new path, and some extra bytes for in DoResolveRelativePath()
328 output->ReserveSizeIfNeeded(base_parsed.path.begin + in DoResolveRelativePath()
329 std::max({path.end(), query.end(), ref.end()})); in DoResolveRelativePath()
330 output->Append(base_url, base_parsed.path.begin); in DoResolveRelativePath()
332 if (path.is_nonempty()) { in DoResolveRelativePath()
333 // The path is replaced or modified. in DoResolveRelativePath()
334 int true_path_begin = output->length(); in DoResolveRelativePath()
337 // colon as part of the path for relative file resolution when the in DoResolveRelativePath()
338 // incoming URL does not provide a drive spec. We save the true path in DoResolveRelativePath()
340 int base_path_begin = base_parsed.path.begin; in DoResolveRelativePath()
344 base_url, base_parsed.path.begin, base_parsed.path.end(), in DoResolveRelativePath()
348 // and we can start appending the rest of the path. |base_path_begin| in DoResolveRelativePath()
353 if (IsSlashOrBackslash(relative_url[path.begin])) { in DoResolveRelativePath()
354 // Easy case: the path is an absolute path on the server, so we can in DoResolveRelativePath()
355 // just replace everything from the path on with the new versions. in DoResolveRelativePath()
357 // always have a path. in DoResolveRelativePath()
358 success &= CanonicalizePath(relative_url, path, in DoResolveRelativePath()
359 output, &out_parsed->path); in DoResolveRelativePath()
361 // Relative path, replace the query, and reference. We take the in DoResolveRelativePath()
362 // original path with the file part stripped, and append the new path. in DoResolveRelativePath()
364 size_t path_begin = output->length(); in DoResolveRelativePath()
365 CopyToLastSlash(base_url, base_path_begin, base_parsed.path.end(), in DoResolveRelativePath()
367 success &= CanonicalizePartialPathInternal(relative_url, path, path_begin, in DoResolveRelativePath()
369 out_parsed->path = MakeRange(path_begin, output->length()); in DoResolveRelativePath()
371 // Copy the rest of the stuff after the path from the relative path. in DoResolveRelativePath()
376 output, &out_parsed->query); in DoResolveRelativePath()
377 CanonicalizeRef(relative_url, ref, output, &out_parsed->ref); in DoResolveRelativePath()
379 // Fix the path beginning to add back the "C:" we may have written above. in DoResolveRelativePath()
380 out_parsed->path = MakeRange(true_path_begin, out_parsed->path.end()); in DoResolveRelativePath()
384 // If we get here, the path is unchanged: copy to output. in DoResolveRelativePath()
385 CopyOneComponent(base_url, base_parsed.path, output, &out_parsed->path); in DoResolveRelativePath()
391 output, &out_parsed->query); in DoResolveRelativePath()
392 CanonicalizeRef(relative_url, ref, output, &out_parsed->ref); in DoResolveRelativePath()
396 // If we get here, the query is unchanged: copy to output. Note that the in DoResolveRelativePath()
398 // have to add it manually if there is a component. in DoResolveRelativePath()
400 output->push_back('?'); in DoResolveRelativePath()
401 CopyOneComponent(base_url, base_parsed.query, output, &out_parsed->query); in DoResolveRelativePath()
405 CanonicalizeRef(relative_url, ref, output, &out_parsed->ref); in DoResolveRelativePath()
410 // that some component is being replaced. in DoResolveRelativePath()
417 // should be kept from the original URL is the scheme.
428 Parsed relative_parsed; // Everything but the scheme is valid. in DoResolveRelativeHost()
429 // TODO(crbug.com/1416006): Support non-special URLs. in DoResolveRelativeHost()
440 replacements.SetPath(relative_url, relative_parsed.path); in DoResolveRelativeHost()
446 output->ReserveSizeIfNeeded( in DoResolveRelativeHost()
451 // A path with an authority section gets canonicalized under standard URL in DoResolveRelativeHost()
459 // Resolves a relative URL that happens to be an absolute file path. Examples
460 // include: "//hostname/path", "/c:/foo", and "//hostname/c:/foo".
468 // as we do for determining if the file is absolute, in which case it will in DoResolveAbsoluteFile()
489 // |base_parsed| is the starting point for our output. Since we may have in DoResolveRelativeURL()
492 bool potentially_dangling_markup = out_parsed->potentially_dangling_markup; in DoResolveRelativeURL()
495 out_parsed->potentially_dangling_markup = true; in DoResolveRelativeURL()
499 // paths (even the default path of "/" is OK). in DoResolveRelativeURL()
502 if (base_parsed.path.is_empty()) { in DoResolveRelativeURL()
503 // On error, return the input (resolving a relative URL on a non-relative in DoResolveRelativeURL()
507 output->push_back(base_url[i]); in DoResolveRelativeURL()
514 base_len -= base_parsed.ref.len + 1; in DoResolveRelativeURL()
515 out_parsed->ref.reset(); in DoResolveRelativeURL()
516 output->Append(base_url, base_len); in DoResolveRelativeURL()
524 // On Windows, two slashes for a file path (regardless of which direction in DoResolveRelativeURL()
526 // that it's an absolute UNC path (we use the base_is_file flag to control in DoResolveRelativeURL()
527 // how strict the UNC finder is). in DoResolveRelativeURL()
529 // We also allow Windows absolute drive specs on any scheme (for example in DoResolveRelativeURL()
532 // as a path. For file URLs, we allow any number of slashes since that would in DoResolveRelativeURL()
533 // be setting the path. in DoResolveRelativeURL()
535 // This assumes the absolute path resolver handles absolute URLs like this in DoResolveRelativeURL()
559 // Any other double-slashes mean that this is relative to the scheme. in DoResolveRelativeURL()
566 // When we get here, we know that the relative URL is on the same host. in DoResolveRelativeURL()