static ALWAYS_INLINE void visitedURLInline(const KURL& base, const AtomicString& attributeURL, Vector<UChar, 512>& buffer) { if (attributeURL.isNull()) return; const UChar* characters = attributeURL.characters(); unsigned length = attributeURL.length(); // This is a poor man's completeURL. Faster with less memory allocation. // FIXME: It's missing a lot of what completeURL does and a lot of what KURL does. // For example, it does not handle international domain names properly. // FIXME: It is wrong that we do not do further processing on strings that have "://" in them: // 1) The "://" could be in the query or anchor. // 2) The URL's path could have a "/./" or a "/../" or a "//" sequence in it. // FIXME: needsTrailingSlash does not properly return true for a URL that has no path, but does // have a query or anchor. bool hasColonSlashSlash = containsColonSlashSlash(characters, length); if (hasColonSlashSlash && !needsTrailingSlash(characters, length)) { buffer.append(attributeURL.characters(), attributeURL.length()); return; } if (hasColonSlashSlash) { // FIXME: This is incorrect for URLs that have a query or anchor; the "/" needs to go at the // end of the path, *before* the query or anchor. buffer.append(characters, length); buffer.append('/'); return; } if (!length) buffer.append(base.string().characters(), base.string().length()); else { switch (characters[0]) { case '/': buffer.append(base.string().characters(), base.pathStart()); break; case '#': buffer.append(base.string().characters(), base.pathEnd()); break; default: buffer.append(base.string().characters(), base.pathAfterLastSlash()); break; } } buffer.append(characters, length); cleanPath(buffer); if (needsTrailingSlash(buffer.data(), buffer.size())) { // FIXME: This is incorrect for URLs that have a query or anchor; the "/" needs to go at the // end of the path, *before* the query or anchor. buffer.append('/'); } return; }
static String protectionSpaceMapKeyFromURL(const KURL& url) { ASSERT(url.isValid()); // Remove the last path component that is not a directory to determine the subtree for which credentials will apply. // We keep a leading slash, but remove a trailing one. String directoryURL = url.string().substring(0, url.pathEnd()); unsigned directoryURLPathStart = url.pathStart(); ASSERT(directoryURL[directoryURLPathStart] == '/'); if (directoryURL.length() > directoryURLPathStart + 1) { size_t index = directoryURL.reverseFind('/'); ASSERT(index != notFound); directoryURL = directoryURL.substring(0, (index != directoryURLPathStart) ? index : directoryURLPathStart + 1); } return directoryURL; }