Skip to content

Commit 6c7c529

Browse files
committed
prevent scramjet from potentially using a site's overwritten console.log
1 parent 28ce3dd commit 6c7c529

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/client/shared/sourcemaps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default function (client: ScramjetClient, self: Self) {
205205
apply(ctx) {
206206
const before = performance.now();
207207
doUnrewrite(ctx);
208-
dbg.time(client.meta, before, `scramtag unrewrite for ${ctx.fn.name}`);
208+
// dbg.time(client.meta, before, `scramtag unrewrite for ${ctx.fn.name}`);
209209
},
210210
});
211211
}

src/log.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { flagEnabled } from "./scramjet";
22
import type { URLMeta } from "./shared/rewriters/url";
33

4+
const logfuncs = {
5+
log: console.log,
6+
warn: console.warn,
7+
error: console.error,
8+
debug: console.debug,
9+
info: console.info,
10+
};
11+
412
export default {
513
fmt: function (severity: string, message: string, ...args: any[]) {
614
const old = Error.prepareStackTrace;
@@ -36,7 +44,7 @@ export default {
3644
this.print(severity, fmt, message, ...args);
3745
},
3846
print(severity: string, tag: string, message: string, ...args: any[]) {
39-
const fn = console[severity] || console.log;
47+
const fn = logfuncs[severity] || logfuncs.log;
4048
const bg = {
4149
log: "#000",
4250
warn: "#f80",

0 commit comments

Comments
 (0)