From 3a51611161ac996e8353a6dd91c4452afa42e8b2 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 25 Jul 2026 22:35:45 +0200 Subject: [PATCH] Update tests and docs --- src/lib/url_util.test.ts | 10 +++++----- src/lib/url_util.ts | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib/url_util.test.ts b/src/lib/url_util.test.ts index 05fe5d56..4da29669 100644 --- a/src/lib/url_util.test.ts +++ b/src/lib/url_util.test.ts @@ -346,18 +346,18 @@ function test_url_graft_path() { function test_url_query_interpolation() { let cases = [ - ["http://example.com/%s000", "a/query", "http://example.com/a/query000"], + ["http://example.com/%s000", "a/query", "http://example.com/a%2Fquery000"], [ - // not percent-encoded and appended + // appended to the path "http://example.com", "a/query", - "http://example.com/a/query", + "http://example.com/a%2Fquery", ], [ - // not percent-encoded and interpolated + // interpolated into the path "http://example.com/%s/path", "a/query", - "http://example.com/a/query/path", + "http://example.com/a%2Fquery/path", ], [ // percent-encoded and appended diff --git a/src/lib/url_util.ts b/src/lib/url_util.ts index dddf3d16..1150c365 100644 --- a/src/lib/url_util.ts +++ b/src/lib/url_util.ts @@ -439,14 +439,13 @@ export function searchUrlToArgs( * If the URL pattern contains "%s", the query is interpolated there. If not, * it is appended to the end of the pattern. * - * If the interpolation point is in the query string of the URL, it is - * percent encoded, otherwise it is is inserted verbatim. + * The search item is percent encoded before it is inserted. * * @param urlPattern a URL to interpolate/append a query to * @param query a query to interpolate/append into the URL * - * @return the URL with the query encoded (if needed) and - * inserted at the relevant point + * @return the URL with the query encoded and inserted at the + * relevant point */ export function interpolateSearchItem(urlPattern: URL, query: string): URL { const hasInterpolationPoint = urlPattern.href.includes("%s")