mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
update: check if entered text is url
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include <QRandomGenerator>
|
||||
#include <QStandardPaths>
|
||||
#include <QUrlQuery>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/api/apiDefs.h"
|
||||
#include "core/api/apiUtils.h"
|
||||
@@ -105,7 +104,6 @@ bool ImportController::httpGet(const QUrl &url)
|
||||
QString text;
|
||||
if (isValidBase64(data)) {
|
||||
qDebug() << "Data is a base64 string\n";
|
||||
// decoded = QByteArray::fromBase64(data, QByteArray::Base64UrlEncoding);
|
||||
decoded = base64Decode(data);
|
||||
text = QString::fromUtf8(decoded).trimmed();
|
||||
} else {
|
||||
@@ -119,13 +117,15 @@ bool ImportController::httpGet(const QUrl &url)
|
||||
qDebug() << text << "\n";
|
||||
|
||||
for (const QString &cfg : configs) {
|
||||
if (cfg.startsWith("vmess://"))
|
||||
if (cfg.startsWith("vless://"))
|
||||
qDebug() << cfg;
|
||||
else if (cfg.startsWith("vless://"))
|
||||
else if (cfg.startsWith("vmess://"))
|
||||
qDebug() << cfg;
|
||||
else if (cfg.startsWith("trojan://"))
|
||||
qDebug() << cfg;
|
||||
else if (cfg.startsWith("ss://"))
|
||||
qDebug() << cfg;
|
||||
else if (cfg.startsWith("trojan://"))
|
||||
else if (cfg.startsWith("ssd://"))
|
||||
qDebug() << cfg;
|
||||
else
|
||||
qDebug() << "Unknown protocol:\n" << cfg.left(10);
|
||||
|
||||
@@ -187,47 +187,26 @@ PageType {
|
||||
|
||||
text: qsTr("Continue")
|
||||
|
||||
function isValidUrl(text) {
|
||||
try {
|
||||
var u = new URL(text)
|
||||
return u.protocol === "http:" || u.protocol === "https:"
|
||||
} catch(e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
clickedFunc: function() {
|
||||
if (isValidUrl(textKey.textField.text)) {
|
||||
ImportController.httpGet(textKey.textField.text)
|
||||
return
|
||||
}
|
||||
if (ImportController.extractConfigFromData(textKey.textField.text)) {
|
||||
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextFieldWithHeaderType {
|
||||
id: texturl
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 32
|
||||
Layout.rightMargin: 16
|
||||
Layout.leftMargin: 16
|
||||
|
||||
headerText: qsTr("Insert url")
|
||||
buttonText: qsTr("Insert")
|
||||
|
||||
clickedFunc: function() {
|
||||
textField.text = ""
|
||||
textField.paste()
|
||||
}
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
id: urlcontinueButton
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
Layout.leftMargin: 16
|
||||
|
||||
visible: texturl.textField.text !== ""
|
||||
|
||||
text: qsTr("Continue")
|
||||
|
||||
clickedFunc: function() {
|
||||
ImportController.httpGet(texturl.textField.text)
|
||||
}
|
||||
}
|
||||
|
||||
ParagraphTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 32
|
||||
|
||||
Reference in New Issue
Block a user