Skip to content

Commit 51c2792

Browse files
committed
config: client: trim slash in url
1 parent c56b49c commit 51c2792

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/server/client/printer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function fetchTask(c) {
106106
const printersInfo: any[] = await getPrinters();
107107
const tasks = [];
108108
for (let i = 0; i < config.printMergeQueue; i++) {
109-
const { body } = await post(`${c.server}/client/${c.token}/print`)
109+
const { body } = await post(`${c.server}client/${c.token}/print`)
110110
.send({
111111
printers: config.printers,
112112
printersInfo: JSON.stringify(printersInfo.map((p) => ({
@@ -123,7 +123,7 @@ async function fetchTask(c) {
123123
if (body.doc) {
124124
tasks.push(body.doc);
125125
// FIXME: so ugly, give server merge task number
126-
if (config.printMergeQueue !== 1) await post(`${c.server}/client/${c.token}/doneprint/${body.doc._id}`);
126+
if (config.printMergeQueue !== 1) await post(`${c.server}client/${c.token}/doneprint/${body.doc._id}`);
127127
}
128128
}
129129
if (tasks.length) {
@@ -137,7 +137,7 @@ async function fetchTask(c) {
137137
throw e;
138138
}
139139
for (const doc of tasks) {
140-
await post(`${c.server}/client/${c.token}/doneprint/${doc._id}?printer=${JSON.stringify(printer)}`);
140+
await post(`${c.server}client/${c.token}/doneprint/${doc._id}?printer=${JSON.stringify(printer)}`);
141141
logger.info(`Print task ${doc.tid}#${doc._id} completed.`);
142142
}
143143
} else {

packages/server/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const serverSchema = Schema.intersect([
8686
]),
8787
]);
8888
const clientSchema = Schema.object({
89-
server: Schema.string().role('url').required(),
89+
server: Schema.transform(String, (i) => (i.endsWith('/') ? i : `${i}/`)).role('url').required(),
9090
balloon: Schema.string(),
9191
balloonLang: Schema.union(['zh', 'en']).default('zh').required(),
9292
balloonType: Schema.union([58, 80, 'plain']).default(80),

0 commit comments

Comments
 (0)