QUrl/doc: explain that the scheme-less URL is probably not intended
It is a valid URL reference, which is not what people may want. Fixes: QTBUG-109855 Change-Id: I69ecc04064514f939896fffd173783ce2228c1d2 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit ce8fc1e88eef63308781d601dd10f694622abf95) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4ed94a237d
commit
6e011cd19d
@ -1,6 +1,14 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
|
//! [constructor-url-reference]
|
||||||
|
QUrl url("example.com");
|
||||||
|
//! [constructor-url-reference]
|
||||||
|
|
||||||
|
//! [constructor-url]
|
||||||
|
QUrl url("https://example.com");
|
||||||
|
//! [constructor-url]
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
QUrl url("http://www.example.com/List of holidays.xml");
|
QUrl url("http://www.example.com/List of holidays.xml");
|
||||||
// url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
|
// url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
|
||||||
|
@ -14,14 +14,16 @@
|
|||||||
\ingroup network
|
\ingroup network
|
||||||
\ingroup shared
|
\ingroup shared
|
||||||
|
|
||||||
|
|
||||||
It can parse and construct URLs in both encoded and unencoded
|
It can parse and construct URLs in both encoded and unencoded
|
||||||
form. QUrl also has support for internationalized domain names
|
form. QUrl also has support for internationalized domain names
|
||||||
(IDNs).
|
(IDNs).
|
||||||
|
|
||||||
The most common way to use QUrl is to initialize it via the
|
The most common way to use QUrl is to initialize it via the constructor by
|
||||||
constructor by passing a QString. Otherwise, setUrl() can also
|
passing a QString containing a full URL. QUrl objects can also be created
|
||||||
be used.
|
from a QByteArray containing a full URL using QUrl::fromEncoded(), or
|
||||||
|
heuristically from incomplete URLs using QUrl::fromUserInput(). The URL
|
||||||
|
representation can be obtained from a QUrl using either QUrl::toString() or
|
||||||
|
QUrl::toEncoded().
|
||||||
|
|
||||||
URLs can be represented in two forms: encoded or unencoded. The
|
URLs can be represented in two forms: encoded or unencoded. The
|
||||||
unencoded representation is suitable for showing to users, but
|
unencoded representation is suitable for showing to users, but
|
||||||
@ -1792,7 +1794,20 @@ inline void QUrlPrivate::validate() const
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a URL by parsing \a url. QUrl will automatically percent encode
|
Constructs a URL by parsing \a url. Note this constructor expects a proper
|
||||||
|
URL or URL-Reference and will not attempt to guess intent. For example, the
|
||||||
|
following declaration:
|
||||||
|
|
||||||
|
\snippet code/src_corelib_io_qurl.cpp constructor-url-reference
|
||||||
|
|
||||||
|
Will construct a valid URL but it may not be what one expects, as the
|
||||||
|
scheme() part of the input is missing. For a string like the above,
|
||||||
|
applications may want to use fromUserInput(). For this constructor or
|
||||||
|
setUrl(), the following is probably what was intended:
|
||||||
|
|
||||||
|
\snippet code/src_corelib_io_qurl.cpp constructor-url
|
||||||
|
|
||||||
|
QUrl will automatically percent encode
|
||||||
all characters that are not allowed in a URL and decode the percent-encoded
|
all characters that are not allowed in a URL and decode the percent-encoded
|
||||||
sequences that represent an unreserved character (letters, digits, hyphens,
|
sequences that represent an unreserved character (letters, digits, hyphens,
|
||||||
underscores, dots and tildes). All other characters are left in their
|
underscores, dots and tildes). All other characters are left in their
|
||||||
|
Loading…
x
Reference in New Issue
Block a user