Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

linkifiers: Replace url-template with uri-template-lite.

Shubham Padia639239a0eab5
diff --git a/package.json b/package.json
index f0c59757b50..9269e7b5f07 100644
--- a/package.json
+++ b/package.json
@@ -86,8 +86,8 @@
"textarea-caret": "^3.1.0",
"tippy.js": "^6.3.7",
"turndown": "^7.0.0",
+ "uri-template-lite": "^23.4.0",
"url-loader": "^4.1.1",
- "url-template": "^3.1.1",
"webfonts-loader": "^8.0.0",
"webpack": "^5.61.0",
"webpack-bundle-tracker": "^3.0.1",
@@ -126,6 +126,7 @@
"@types/throttle-debounce": "^5.0.2",
"@types/tinycolor2": "^1.4.5",
"@types/turndown": "^5.0.1",
+ "@types/uri-template-lite": "^19.12.4",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"@typescript-eslint/utils": "^8.25.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f675fbd48a7..7fa2adb9685 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -281,12 +281,12 @@ importers:
turndown:
specifier: ^7.0.0
version: 7.2.2
+ uri-template-lite:
+ specifier: ^23.4.0
+ version: 23.4.0
url-loader:
specifier: ^4.1.1
version: 4.1.1([email protected])
- url-template:
- specifier: ^3.1.1
- version: 3.1.1
webfonts-loader:
specifier: ^8.0.0
version: 8.1.1
@@ -396,6 +396,9 @@ importers:
'@types/turndown':
specifier: ^5.0.1
version: 5.0.6
+ '@types/uri-template-lite':
+ specifier: ^19.12.4
+ version: 19.12.4
'@typescript-eslint/eslint-plugin':
specifier: ^8.2.0
@@ -2989,6 +2992,9 @@ packages:
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-VH2NRKCLHIub2sK7NEURt5c09BsdXPPcduc1bY0w9PSbphs1zVDWf++rEn1LfV9PzU8yyoD1UyEkI0DcMnMnHw==}
+
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
@@ -9460,6 +9466,9 @@ packages:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
+ resolution: {integrity: sha512-JsAjquFMpSyZRWAUQguhHIRuh4jb/xDhwQyb1/7C42YLJgkc5WoBF3UkRRM1QtL6Vr9xBa9fB7q3xPzXRwvuUA==}
+
resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==}
@@ -9476,10 +9485,6 @@ packages:
resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==}
- resolution: {integrity: sha512-4oszoaEKE/mQOtAmdMWqIRHmkxWkUZMnXFnjQ5i01CuRSK3uluxcH1MRVVVWmhlnzT1SCDfKxxficm2G37qzCA==}
- engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
-
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
@@ -12764,6 +12769,8 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]': {}
+
dependencies:
'@types/node': 24.10.7
@@ -21233,6 +21240,8 @@ snapshots:
dependencies:
punycode: 2.3.1
+
@@ -21247,8 +21256,6 @@ snapshots:
querystringify: 2.2.0
requires-port: 1.0.0
-
diff --git a/version.py b/version.py
index 7a10f9dfa9f..ded3f7afd27 100644
--- a/version.py
+++ b/version.py
@@ -50,4 +50,4 @@ API_FEATURE_LEVEL = 448
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
-PROVISION_VERSION = (365, 0) # bumped 2026-01-13 to upgrade Python requirements
+PROVISION_VERSION = (366, 0) # bumped 2026-01-14 to add uri-template-lite
diff --git a/web/src/linkifiers.ts b/web/src/linkifiers.ts
index e5e6d3eded6..e8741564378 100644
--- a/web/src/linkifiers.ts
+++ b/web/src/linkifiers.ts
@@ -1,4 +1,4 @@
-import * as url_template_lib from "url-template";
+import Template from "uri-template-lite";
import type * as z from "zod/mini";
import * as blueslip from "./blueslip.ts";
@@ -6,7 +6,7 @@ import type {realm_linkifier_schema} from "./state_data.ts";
type LinkifierMap = Map<
RegExp,
- {url_template: url_template_lib.Template; group_number_to_name: Record<number, string>}
+ {url_template: Template; group_number_to_name: Record<number, string>}
>;
const linkifier_map: LinkifierMap = new Map();
@@ -19,7 +19,7 @@ export function get_linkifier_map(): LinkifierMap {
export function python_to_js_linkifier(
pattern: string,
url: string,
-): [RegExp | null, url_template_lib.Template, Record<number, string>] {
+): [RegExp | null, Template, Record<number, string>] {
// Converts a python named-group regex to a javascript-compatible numbered
// group regex... with a regex!
const named_group_re = /\(?P<([^>]+?)>/g;
@@ -81,7 +81,7 @@ export function python_to_js_linkifier(
throw error;
}
}
- const url_template = url_template_lib.parseTemplate(url);
+ const url_template = new Template(url);
return [final_regex, url_template, group_number_to_name];
}
diff --git a/web/src/markdown.ts b/web/src/markdown.ts
index 2fa5fa2e35f..fa5dd91dc98 100644
--- a/web/src/markdown.ts
+++ b/web/src/markdown.ts
@@ -2,7 +2,7 @@ import {getUnixTime, isValid} from "date-fns";
import katex from "katex";
import _ from "lodash";
import assert from "minimalistic-assert";
-import type {Template} from "url-template";
+import type Template from "uri-template-lite";
import render_channel_message_link from "../templates/channel_message_link.hbs";
import render_topic_link from "../templates/topic_link.hbs";
diff --git a/web/src/playground_links_popover.ts b/web/src/playground_links_popover.ts
index bab905969a3..8557e149ab1 100644
--- a/web/src/playground_links_popover.ts
+++ b/web/src/playground_links_popover.ts
@@ -1,6 +1,6 @@
import $ from "jquery";
import type * as tippy from "tippy.js";
-import * as url_template_lib from "url-template";
+import Template from "uri-template-lite";
import render_playground_links_popover from "../templates/popovers/playground_links_popover.hbs";
@@ -117,15 +117,13 @@ function register_click_handlers(): void {
// a popover is shown.
const extracted_code = $codehilite_div.find("code").text();
if (playground_info.length === 1 && playground_info[0] !== undefined) {
- const url_template = url_template_lib.parseTemplate(
- playground_info[0].url_template,
- );
+ const url_template = new Template(playground_info[0].url_template);
const playground_url = url_template.expand({code: extracted_code});
window.open(playground_url, "_blank", "noopener,noreferrer");
} else {
const playground_store = new Map<number, RealmPlaygroundWithURL>();
for (const playground of playground_info) {
- const url_template = url_template_lib.parseTemplate(playground.url_template);
+ const url_template = new Template(playground.url_template);
const playground_url = url_template.expand({code: extracted_code});
playground_store.set(playground.id, {...playground, playground_url});
}
diff --git a/web/tests/markdown_parse.test.cjs b/web/tests/markdown_parse.test.cjs
index 7973a826298..f075dbae16e 100644
--- a/web/tests/markdown_parse.test.cjs
+++ b/web/tests/markdown_parse.test.cjs
@@ -2,7 +2,7 @@
const assert = require("node:assert/strict");
-const url_template_lib = require("url-template");
+const Template = require("uri-template-lite");
const {zrequire} = require("./lib/namespace.cjs");
const {run_test} = require("./lib/test.cjs");
@@ -118,7 +118,7 @@ const linkifier_map = new Map([
[
regex,
{
- url_template: url_template_lib.parseTemplate("http://foo.com/{id}"),
+ url_template: new Template("http://foo.com/{id}"),
group_number_to_name: {1: "id"},
},
],
diff --git a/web/third/marked/lib/marked.d.cts b/web/third/marked/lib/marked.d.cts
index e229afb892b..5da788db317 100644
--- a/web/third/marked/lib/marked.d.cts
+++ b/web/third/marked/lib/marked.d.cts
@@ -4,7 +4,6 @@ we only use parts of the marked API and are using a fork
of the upstream library.
*/
-import {PrimitiveValue} from "url-template";
declare class Renderer {
code: (code: string) => string;
@@ -18,8 +17,8 @@ declare namespace marked {
| {
exec(string: string): RegExpExecArray | null;
};
-
- type LinkifierMatch = PrimitiveValue | PrimitiveValue[] | Record<string, PrimitiveValue>;
+ // uri-template-lite has this type set as unknown.
+ type LinkifierMatch = unknown;
type ParseOptions = {
get_linkifier_regexes: () => RegExp[];