src/corelib/io/qurl.cpp
changeset 30 5dc02b23752f
parent 29 b72c6db6890b
child 37 758a864f9613
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   165     Note that the case folding rules in \l{RFC 3491}{Nameprep}, which QUrl
   165     Note that the case folding rules in \l{RFC 3491}{Nameprep}, which QUrl
   166     conforms to, require host names to always be converted to lower case,
   166     conforms to, require host names to always be converted to lower case,
   167     regardless of the Qt::FormattingOptions used.
   167     regardless of the Qt::FormattingOptions used.
   168 */
   168 */
   169 
   169 
       
   170 /*!
       
   171  \fn uint qHash(const QUrl &url)
       
   172  \since 4.7
       
   173  \relates QUrl
       
   174 
       
   175  Computes a hash key from the normalized version of \a url.
       
   176  */
   170 #include "qplatformdefs.h"
   177 #include "qplatformdefs.h"
   171 #include "qurl.h"
   178 #include "qurl.h"
   172 #include "private/qunicodetables_p.h"
   179 #include "private/qunicodetables_p.h"
   173 #include "qatomic.h"
   180 #include "qatomic.h"
   174 #include "qbytearray.h"
   181 #include "qbytearray.h"
  3483 }
  3490 }
  3484 
  3491 
  3485 void QUrlPrivate::setAuthority(const QString &auth)
  3492 void QUrlPrivate::setAuthority(const QString &auth)
  3486 {
  3493 {
  3487     isHostValid = true;
  3494     isHostValid = true;
  3488     if (auth.isEmpty())
  3495     if (auth.isEmpty()) {
       
  3496         setUserInfo(QString());
       
  3497         host.clear();
       
  3498         port = -1;
  3489         return;
  3499         return;
       
  3500     }
  3490 
  3501 
  3491     // find the port section of the authority by searching from the
  3502     // find the port section of the authority by searching from the
  3492     // end towards the beginning for numbers until a ':' is reached.
  3503     // end towards the beginning for numbers until a ':' is reached.
  3493     int portIndex = auth.length() - 1;
  3504     int portIndex = auth.length() - 1;
  3494     if (portIndex == 0) {
  3505     if (portIndex == 0) {
  5555     }
  5566     }
  5556     t.setFragment(relative.fragment());
  5567     t.setFragment(relative.fragment());
  5557     removeDotsFromPath(&t.d->encodedPath);
  5568     removeDotsFromPath(&t.d->encodedPath);
  5558     t.d->path.clear();
  5569     t.d->path.clear();
  5559 
  5570 
       
  5571 #if defined(QURL_DEBUG)
       
  5572     qDebug("QUrl(\"%s\").resolved(\"%s\") = \"%s\"",
       
  5573            toEncoded().constData(),
       
  5574            relative.toEncoded().constData(),
       
  5575            t.toEncoded().constData());
       
  5576 #endif
  5560     return t;
  5577     return t;
  5561 }
  5578 }
  5562 
  5579 
  5563 /*!
  5580 /*!
  5564     Returns true if the URL is relative; otherwise returns false. A
  5581     Returns true if the URL is relative; otherwise returns false. A
  6376     // Check first for files, since on Windows drive letters can be interpretted as schemes
  6393     // Check first for files, since on Windows drive letters can be interpretted as schemes
  6377     if (QDir::isAbsolutePath(trimmedString))
  6394     if (QDir::isAbsolutePath(trimmedString))
  6378         return QUrl::fromLocalFile(trimmedString);
  6395         return QUrl::fromLocalFile(trimmedString);
  6379 
  6396 
  6380     QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode);
  6397     QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode);
  6381     QUrl urlPrepended = QUrl::fromEncoded((QLatin1String("http://") + trimmedString).toUtf8(), QUrl::TolerantMode);
  6398     QUrl urlPrepended = QUrl::fromEncoded("http://" + trimmedString.toUtf8(), QUrl::TolerantMode);
  6382 
  6399 
  6383     // Check the most common case of a valid url with scheme and host
  6400     // Check the most common case of a valid url with scheme and host
  6384     // We check if the port would be valid by adding the scheme to handle the case host:port
  6401     // We check if the port would be valid by adding the scheme to handle the case host:port
  6385     // where the host would be interpretted as the scheme
  6402     // where the host would be interpretted as the scheme
  6386     if (url.isValid()
  6403     if (url.isValid()