Skip to content

Commit 7b80188

Browse files
helpz: fix context generation
add .host and .path Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
1 parent 1580303 commit 7b80188

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

_helpz/generate.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ function getRenderContext(globalVars, zconf, inputVars) {
173173
});
174174
const data = flattenData(globalValues);
175175
data.endpoint = data.urlpath;
176+
const url = new URL(data.urlpath);
177+
data.host = url.host;
178+
data.path = url.pathname;
176179
if (inputVars) {
177180
const localValues = {};
178181
inputVars.split(" ").forEach((inputName) => {

_src/entrypoints/help.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ const attachCopyButton = (preElem: Element, getRawCode: () => string) => {
143143
const endpoint = new URL(data.urlpath as string);
144144
endpoint.protocol = (data.scheme + ":") as string;
145145
data.endpoint = endpoint.toString();
146+
data.host = endpoint.host;
147+
data.path = endpoint.pathname;
146148
Object.entries(flattenData(tmplData[codeId].value)).forEach(([k, v]) => {
147149
data[k] = v;
148150
});

0 commit comments

Comments
 (0)