mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-09-17 09:54:29 +00:00
Keep generated test URLs readable
This commit is contained in:
@@ -449,17 +449,27 @@
|
||||
}).format(new Date(milliseconds));
|
||||
}
|
||||
|
||||
function readableQueryValue(value) {
|
||||
return encodeURIComponent(String(value))
|
||||
.replace(/%3A/gi, ":")
|
||||
.replace(/%2F/gi, "/");
|
||||
}
|
||||
|
||||
function configuredUrl(config, baseUrl) {
|
||||
const url = new URL(baseUrl);
|
||||
url.search = "";
|
||||
url.searchParams.set("start", new Date(config.startMs).toISOString());
|
||||
url.searchParams.set("end", new Date(config.endMs).toISOString());
|
||||
url.searchParams.set("tz", config.tz);
|
||||
url.searchParams.set("freq", config.freqText);
|
||||
url.searchParams.set("bw", config.bwText);
|
||||
url.searchParams.set("sf", String(config.sf));
|
||||
url.searchParams.set("cr", String(config.cr));
|
||||
url.searchParams.set("tx", config.txText);
|
||||
const values = [
|
||||
["start", new Date(config.startMs).toISOString()],
|
||||
["end", new Date(config.endMs).toISOString()],
|
||||
["tz", config.tz],
|
||||
["freq", config.freqText],
|
||||
["bw", config.bwText],
|
||||
["sf", String(config.sf)],
|
||||
["cr", String(config.cr)],
|
||||
["tx", config.txText],
|
||||
];
|
||||
url.search = "?" + values.map(function (entry) {
|
||||
return entry[0] + "=" + readableQueryValue(entry[1]);
|
||||
}).join("&");
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -266,9 +266,9 @@ clock</code></pre>
|
||||
<div class="preset-test-generator-disclosure-body">
|
||||
<p>
|
||||
Enter the test times in the selected time zone and choose the radio
|
||||
tuple. The generated URL converts the times to exact UTC instants and
|
||||
keeps <code>tz</code> so the page displays them in the organizer's local
|
||||
time zone.
|
||||
tuple. The generated URL converts the times to exact UTC instants, keeps
|
||||
the date punctuation readable, and keeps <code>tz</code> so the page
|
||||
displays them in the organizer's local time zone.
|
||||
</p>
|
||||
|
||||
<div class="preset-test-generator-layout">
|
||||
|
||||
+1
-1
@@ -28,4 +28,4 @@ extra_javascript:
|
||||
- _javascript/firmware_picker.js
|
||||
- _javascript/telemetry_decoder.js
|
||||
- _javascript/filter_tool.js
|
||||
- _javascript/preset_test.js?v=20260916-4
|
||||
- _javascript/preset_test.js?v=20260916-5
|
||||
|
||||
@@ -183,6 +183,12 @@ const shared = new URL(tool.configuredUrl(
|
||||
changed,
|
||||
"https://example.test/preset-test/?stale=yes#commands"
|
||||
));
|
||||
assert.strictEqual(
|
||||
shared.href,
|
||||
"https://example.test/preset-test/?start=2026-09-22T00:00:00.000Z" +
|
||||
"&end=2026-09-24T00:00:00.000Z&tz=America/Los_Angeles" +
|
||||
"&freq=915.25&bw=125&sf=10&cr=5&tx=22#commands"
|
||||
);
|
||||
assert.strictEqual(shared.searchParams.get("start"), "2026-09-22T00:00:00.000Z");
|
||||
assert.strictEqual(shared.searchParams.get("end"), "2026-09-24T00:00:00.000Z");
|
||||
assert.strictEqual(shared.searchParams.get("freq"), "915.25");
|
||||
|
||||
Reference in New Issue
Block a user