+1








766fb96ff2
* Adding support for hosting with URL prefix to make reverse-proxy setup on sub-path possible
* Adjusting recent changes to auth.html (changing to relative URLs) after rebasing from upstream
* Adjusting service_worker and application manifest to support URL-prefix
* Add notes on Space Lua Pattern Matching (#1366)
* Remove common/space_lua/stdlib/math.md (#1371)
* Escape pipe symbol in string.gsub (#1370)
* feat: configure vim in CONFIG (#1369)
* Fix week calculation (#1368)
* Add more tests for week calculation
* Fix week calculation
* Add more tests
* Implement Lua built-in function os.difftime (#1367)
* Implement Lua built-in function os.difftime
* Test os.difftime
---------
Co-authored-by: Zef Hemel <zef@zef.me>
* Fix index page naming during server initialization (#1365)
* Allow non-zero shell exit codes (#1377)
* Generate version from git describe at build time (#1374)
* Generate version from git describe at build time
* Add 2.0-beta prefix
* Use Deno.Command instead of Deno.run
* Add missing case to math.random and check arguments (#1372)
* Fix paragraphs for the tag page (#1376)
* Render a predefined string for empty markdown table instead of pipe characters (#1387)
* Fix string.find (#1390)
* Fetch tags and history for proper version string generation (#1388)
* Fix support for disabling shortcuts (#1393)
* Add GitHub Actions Cache to reduce build times (#1394)
* Order strings in queries using collation algorithm (#1391)
Configurable with queryCollation, default value maintains old behaviour.
Added tests, schema, example settings, and documentation to query page.
Close: #614
Close: #1316
* Utility function to handle empty query results and templates (#1386)
* Add global Lua function 'some'
Moved documentation for 'each' function to non-standard section.
* Revert "Add optional argument to template.each for empty collection output (#1359)"
This reverts commit b73dadec67.
* Reimplement #1359 using 'some' function
* Update Lua to event.listEvents to match plugos syscall (#1397)
The documentation, example, and other function names use
`event.listEvents`, but `event.list` is being registered with the
client.
* Update widget header to not overflow container (#1410)
Also add a 10px margin below the header to maintain consistent spacing
around the widget contents.
* fix: case insensitive admonitions by default (#1409)
* fix: closing bracket is missing (#1408)
* Add optional priority attribute to PageCreatingContent (#1392)
* Add optional priority attribute to PageCreatingContent
* Minor simplification
* Fix comments
* Revert changes
* Add pageEventHandlers
* Use UTC year, month, and date for strings lacking time components (#1403)
* feat: allow CONFIG.md in any directory (#1398)
* fix: bundle external dependencies (#1379)
* Deno bump
* Copy-edit splash screen text (#1413)
* Fixes #1401 by implementing Lua's select
* Fixes offline capability of PWA (I hope).
Now storing config in localStorage.
* fix lint
* Reduce blast radius of Lua errors
* Fixes #1411: adds 'priority' setting for space style
* Refactor: Merging common/ into web/
* Fixes #1400
* Improves #1312 by rendering Lua expressions (but not widgets)
* Fix minor typos, add configuration to the docs
---------
Co-authored-by: wbhouston <wmbhouston@gmail.com>
Co-authored-by: Lennart Ochel <lennart.ochel@outlook.com>
Co-authored-by: Matthias Benaets <89214559+MatthiasBenaets@users.noreply.github.com>
Co-authored-by: Zef Hemel <zef@zef.me>
Co-authored-by: Marek S. Łukasiewicz <marek@lukasiewicz.tech>
Co-authored-by: Ivan Alejandro <ivanalejandro0@gmail.com>
Co-authored-by: Albert-Jan de Vries <aj+github@albert-jandevries.nl>
Co-authored-by: Cole Stowell <121599022+costowell@users.noreply.github.com>
Co-authored-by: Jim Tittsler <jimt@onjapan.net>
205 lines
6.3 KiB
TypeScript
205 lines
6.3 KiB
TypeScript
import { assertEquals } from "@std/assert";
|
|
import { applyUrlPrefix, removeUrlPrefix } from "$lib/url_prefix.ts";
|
|
|
|
Deno.test("url_prefix - removeUrlPrefix - with value", async (t) => {
|
|
await t.step("Absolute URL, present, should be removed", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("http://myserver/sb/relevant", "/sb"),
|
|
"http://myserver/relevant",
|
|
);
|
|
assertEquals(
|
|
removeUrlPrefix("https://myserver/sb/relevant", "/sb"),
|
|
"https://myserver/relevant",
|
|
);
|
|
});
|
|
|
|
await t.step("Absolute URL, present, should only remove leading", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("http://myserver/sb/sb/relevant/sb", "/sb"),
|
|
"http://myserver/sb/relevant/sb",
|
|
);
|
|
assertEquals(
|
|
removeUrlPrefix("http://myserver/relevant/sb", "/sb"),
|
|
"http://myserver/relevant/sb",
|
|
);
|
|
});
|
|
|
|
await t.step("Absolute URL, absent, should be untouched", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("http://myserver/other/relevant", "/sb"),
|
|
"http://myserver/other/relevant",
|
|
);
|
|
assertEquals(
|
|
removeUrlPrefix("https://myserver/other/relevant", "/sb"),
|
|
"https://myserver/other/relevant",
|
|
);
|
|
});
|
|
|
|
await t.step("Absolute URL, queryString, should be preserved", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("http://myserver/sb/sb/relevant/sb?param=arg", "/sb"),
|
|
"http://myserver/sb/relevant/sb?param=arg",
|
|
);
|
|
});
|
|
|
|
await t.step("Absolute URL, unsupported, should be untouched", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("ftp://myserver/sb/relevant", "/sb"),
|
|
"ftp://myserver/sb/relevant",
|
|
);
|
|
});
|
|
|
|
await t.step("Host-Relative URL, present, should be removed", () => {
|
|
assertEquals(removeUrlPrefix("/sb/relevant", "/sb"), "/relevant");
|
|
});
|
|
|
|
await t.step("Host-Relative URL, present, should only remove leading", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("/sb/sb/relevant/sb", "/sb"),
|
|
"/sb/relevant/sb",
|
|
);
|
|
assertEquals(removeUrlPrefix("/relevant/sb", "/sb"), "/relevant/sb");
|
|
});
|
|
|
|
await t.step("Host-Relative URL, queryString, should be preserved", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("/sb/sb/relevant/sb?param=arg", "/sb"),
|
|
"/sb/relevant/sb?param=arg",
|
|
);
|
|
assertEquals(
|
|
removeUrlPrefix("/relevant/sb?param=arg", "/sb"),
|
|
"/relevant/sb?param=arg",
|
|
);
|
|
});
|
|
|
|
await t.step("Host-Relative URL, absent, should be untouched", () => {
|
|
assertEquals(removeUrlPrefix("/other/relevant", "/sb"), "/other/relevant");
|
|
});
|
|
|
|
await t.step("Page-Relative URL, should be untouched", () => {
|
|
assertEquals(removeUrlPrefix("sb/relevant", "/sb"), "sb/relevant");
|
|
});
|
|
});
|
|
|
|
Deno.test("url_prefix - removeUrlPrefix - no value", async (t) => {
|
|
await t.step("Absolute URL, should be untouched", () => {
|
|
assertEquals(
|
|
removeUrlPrefix("http://myserver/sb/relevant", ""),
|
|
"http://myserver/sb/relevant",
|
|
);
|
|
assertEquals(
|
|
removeUrlPrefix("https://myserver/sb/relevant"),
|
|
"https://myserver/sb/relevant",
|
|
);
|
|
});
|
|
|
|
await t.step("Host-Relative URL, should be untouched", () => {
|
|
assertEquals(removeUrlPrefix("/sb/relevant", ""), "/sb/relevant");
|
|
assertEquals(removeUrlPrefix("/sb/relevant"), "/sb/relevant");
|
|
});
|
|
|
|
await t.step("Page-Relative URL, should be untouched", () => {
|
|
assertEquals(removeUrlPrefix("sb/relevant", ""), "sb/relevant");
|
|
assertEquals(removeUrlPrefix("sb/relevant"), "sb/relevant");
|
|
});
|
|
});
|
|
|
|
Deno.test("url_prefix - applyUrlPrefix - with value", async (t) => {
|
|
await t.step("string, Absolute URL, should be prefixed", () => {
|
|
assertEquals(
|
|
applyUrlPrefix("http://myserver/relevant", "/sb"),
|
|
"http://myserver/sb/relevant",
|
|
);
|
|
assertEquals(
|
|
applyUrlPrefix("https://myserver/relevant", "/sb"),
|
|
"https://myserver/sb/relevant",
|
|
);
|
|
});
|
|
|
|
await t.step("string, Absolute URL, should not care about dups", () => {
|
|
assertEquals(
|
|
applyUrlPrefix("http://myserver/sb/relevant/sb", "/sb"),
|
|
"http://myserver/sb/sb/relevant/sb",
|
|
);
|
|
});
|
|
|
|
await t.step("string, Absolute URL, queryString should be preserved", () => {
|
|
assertEquals(
|
|
applyUrlPrefix("http://myserver/sb/relevant/sb?param=arg", "/sb"),
|
|
"http://myserver/sb/sb/relevant/sb?param=arg",
|
|
);
|
|
});
|
|
|
|
await t.step("string, Absolute URL, unsupported, should be untouched", () => {
|
|
assertEquals(
|
|
applyUrlPrefix("ftp://myserver/relevant", "/sb"),
|
|
"ftp://myserver/relevant",
|
|
);
|
|
});
|
|
|
|
await t.step("string, Host-Relative URL, should be prefixed", () => {
|
|
assertEquals(applyUrlPrefix("/relevant", "/sb"), "/sb/relevant");
|
|
});
|
|
|
|
await t.step("string, Host-Relative URL, should not care about dups", () => {
|
|
assertEquals(
|
|
applyUrlPrefix("/sb/relevant/sb", "/sb"),
|
|
"/sb/sb/relevant/sb",
|
|
);
|
|
});
|
|
|
|
await t.step(
|
|
"string, Host-Relative URL, queryString should be preserved",
|
|
() => {
|
|
assertEquals(
|
|
applyUrlPrefix("/sb/relevant/sb?param=arg", "/sb"),
|
|
"/sb/sb/relevant/sb?param=arg",
|
|
);
|
|
},
|
|
);
|
|
|
|
await t.step("string, Page-Relative URL, should be untouched", () => {
|
|
assertEquals(applyUrlPrefix("relevant", "/sb"), "relevant");
|
|
});
|
|
|
|
await t.step("URL object, Absolute URL, should be prefixed", () => {
|
|
assertEquals(
|
|
applyUrlPrefix(new URL("http://myserver/relevant"), "/sb"),
|
|
new URL("http://myserver/sb/relevant"),
|
|
);
|
|
});
|
|
|
|
await t.step(
|
|
"URL object, Absolute URL, queryString should be preserved",
|
|
() => {
|
|
assertEquals(
|
|
applyUrlPrefix(new URL("http://myserver/relevant?param=arg"), "/sb"),
|
|
new URL("http://myserver/sb/relevant?param=arg"),
|
|
);
|
|
},
|
|
);
|
|
});
|
|
|
|
Deno.test("url_prefix - applyUrlPrefix - no value", async (t) => {
|
|
await t.step("Absolute URL, should be untouched", () => {
|
|
assertEquals(
|
|
applyUrlPrefix("http://myserver/relevant", ""),
|
|
"http://myserver/relevant",
|
|
);
|
|
assertEquals(
|
|
applyUrlPrefix("https://myserver/relevant"),
|
|
"https://myserver/relevant",
|
|
);
|
|
});
|
|
|
|
await t.step("Host-Relative URL, should be untouched", () => {
|
|
assertEquals(applyUrlPrefix("/relevant", ""), "/relevant");
|
|
assertEquals(applyUrlPrefix("/relevant"), "/relevant");
|
|
});
|
|
|
|
await t.step("Page-Relative URL, should be untouched", () => {
|
|
assertEquals(applyUrlPrefix("relevant", ""), "relevant");
|
|
assertEquals(applyUrlPrefix("relevant"), "relevant");
|
|
});
|
|
});
|