mirror of
https://github.com/openwrt/luci.git
synced 2026-05-31 10:31:55 +08:00
luci-app-https-dns-proxy: bugfixes and resolvers update
* fix templates loading when no template found (thanks @systemcrash!) * fix redundant checks in view (thanks @systemcrash!) * fix/update/delete/add resolvers Signed-off-by: Stan Grishin <stangri@melmac.ca>
This commit is contained in:
+21
-15
@@ -25,21 +25,24 @@ var pkg = {
|
||||
);
|
||||
},
|
||||
templateToRegexp: function (template) {
|
||||
return RegExp(
|
||||
"^" +
|
||||
template
|
||||
.split(/(\{\w+\})/g)
|
||||
.map((part) => {
|
||||
let placeholder = part.match(/^\{(\w+)\}$/);
|
||||
if (placeholder) return `(?<${placeholder[1]}>.*?)`;
|
||||
else return part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
})
|
||||
.join("") +
|
||||
"$"
|
||||
);
|
||||
if (template)
|
||||
return new RegExp(
|
||||
"^" +
|
||||
template
|
||||
.split(/(\{\w+\})/g)
|
||||
.map((part) => {
|
||||
let placeholder = part.match(/^\{(\w+)\}$/);
|
||||
if (placeholder) return `(?<${placeholder[1]}>.*?)`;
|
||||
else return part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
})
|
||||
.join("") +
|
||||
"$"
|
||||
);
|
||||
return new RegExp("");
|
||||
},
|
||||
templateToResolver: function (template, args) {
|
||||
return template.replace(/{(\w+)}/g, (_, v) => args[v]);
|
||||
if (template) return template.replace(/{(\w+)}/g, (_, v) => args[v]);
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -157,8 +160,11 @@ var status = baseclass.extend({
|
||||
force_dns_active: null,
|
||||
version: null,
|
||||
},
|
||||
providers: (data[1] && data[1][pkg.Name]) || { providers: [] },
|
||||
runtime: (data[2] && data[2][pkg.Name]) || { instances: [] },
|
||||
providers: (data[1] && data[1][pkg.Name]) || [{ title: "empty" }],
|
||||
runtime: (data[2] && data[2][pkg.Name]) || {
|
||||
instances: null,
|
||||
triggers: [],
|
||||
},
|
||||
};
|
||||
reply.providers.sort(function (a, b) {
|
||||
return _(a.title).localeCompare(_(b.title));
|
||||
|
||||
Reference in New Issue
Block a user