Merge branch 'serverless-domains' of github.com:sethalves/hifi into serverless-domains

This commit is contained in:
Seth Alves 2018-02-20 16:29:00 -08:00
commit d4a1f6181a
5 changed files with 25 additions and 11 deletions

View file

@ -517,8 +517,19 @@ bool isDomainURL(QUrl url) {
if (!url.isValid()) {
return false;
}
// XXX check ending of path
return url.scheme() == HIFI_URL_SCHEME || url.scheme() == "file" || url.scheme() == "http" || url.scheme() == "https";
if (url.scheme() != HIFI_URL_SCHEME &&
url.scheme() != "file" &&
url.scheme() != "http" &&
url.scheme() != "https") {
return false;
}
if (url.path().endsWith(".domain.json", Qt::CaseInsensitive) ||
url.path().endsWith(".domain.json.gz", Qt::CaseInsensitive)) {
return true;
}
return false;
}
#ifdef Q_OS_WIN

View file

@ -310,9 +310,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
} else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") {
qDebug() << "QQQQ file or http before serverless domain" << lookupUrl.toString();
_previousLookup.clear();
QUrl domainUrl = lookupUrl;
const QString path = PathUtils::expandToAppAbsolutePath(lookupUrl.path());
domainUrl.setPath(path);
QUrl domainUrl = PathUtils::expandToAppAbsolutePath(lookupUrl);
emit setServersEnabled(false);
setDomainInfo(domainUrl, QString(), 0, trigger);
DependencyManager::get<NodeList>()->getDomainHandler().setIsConnected(true);

View file

@ -17,6 +17,7 @@
#include <StatTracker.h>
#include <shared/FileUtils.h>
#include <pathUtils.h>
#include "ResourceManager.h"
@ -28,7 +29,7 @@ void FileResourceRequest::doSend() {
if (_url.scheme() == URL_SCHEME_QRC) {
filename = ":/" + _url.path();
} else {
filename = _url.toLocalFile();
filename = PathUtils::expandToAppAbsolutePath(_url).toLocalFile();
// sometimes on windows, we see the toLocalFile() return null,
// in this case we will attempt to simply use the url as a string
if (filename.isEmpty()) {

View file

@ -133,12 +133,16 @@ QUrl PathUtils::resourcesUrl(const QString& relativeUrl) {
return QUrl(resourcesUrl() + relativeUrl);
}
QString PathUtils::expandToAppAbsolutePath(const QString& filePath) {
QString path = filePath;
QUrl PathUtils::expandToAppAbsolutePath(const QUrl& fileUrl) {
QUrl url = fileUrl;
QString path = fileUrl.path();
if (path.startsWith("/~/")) {
path.replace(1, 2, applicationAbsolutePath());
QString absolutePath = applicationAbsolutePath();
path.replace(0, 3, absolutePath);
url = QUrl("file:///" + path);
qDebug() << "QQQ expanded URL " << url;
}
return path;
return url;
}
const QString& PathUtils::qmlBaseUrl() {
static const QString staticResourcePath = resourcesUrl() + "qml/";

View file

@ -37,7 +37,7 @@ public:
static QUrl resourcesUrl(const QString& relative);
static const QString& resourcesPath();
static const QString& qmlBaseUrl();
static QString expandToAppAbsolutePath(const QString& filePath);
static QUrl expandToAppAbsolutePath(const QUrl& fileUrl);
static QUrl qmlUrl(const QString& relative);
#ifdef DEV_BUILD
static const QString& projectRootPath();