Commit eb0b630 1 parent b287ed1 commit eb0b630 Copy full SHA for eb0b630
File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,11 @@ class SyntaxHighlightRewriter implements HTMLRewriterElementContentHandlers {
18
18
private lang : string = "" ;
19
19
private code : string = "" ;
20
20
cache : KVNamespace ;
21
+ salt : string ;
21
22
22
23
constructor ( private runtime : Runtime [ "runtime" ] ) {
23
24
this . cache = runtime . env . KV_HIGHLIGHT ;
25
+ this . salt = runtime . env . SYNTAX_SALT ;
24
26
}
25
27
26
28
element ( element : Element ) {
@@ -33,7 +35,9 @@ class SyntaxHighlightRewriter implements HTMLRewriterElementContentHandlers {
33
35
if ( text . lastInTextNode ) {
34
36
const hashBuffer = await crypto . subtle . digest (
35
37
"SHA-1" ,
36
- new TextEncoder ( ) . encode ( `${ theme } -${ this . lang } -${ this . code } ` )
38
+ new TextEncoder ( ) . encode (
39
+ `${ this . salt } -${ theme } -${ this . lang } -${ this . code } `
40
+ )
37
41
) ;
38
42
const hashArray = Array . from ( new Uint8Array ( hashBuffer ) ) ;
39
43
const hash = hashArray
@@ -53,7 +57,7 @@ class SyntaxHighlightRewriter implements HTMLRewriterElementContentHandlers {
53
57
this . runtime . ctx . waitUntil ( this . cache . get ( hash ) ) ;
54
58
55
59
const res = await fetch (
56
- `https://just_be- highlight.web. val.run ?lang=${ this . lang } &theme=${ theme } ` ,
60
+ `https://highlight.val.just-be.dev ?lang=${ this . lang } &theme=${ theme } ` ,
57
61
{
58
62
method : "POST" ,
59
63
body : this . code ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ interface Env {
9
9
PUBLISH_KEY : string ;
10
10
SENTRY_DSN : string ;
11
11
SENTRY_AUTH_TOKEN : string ;
12
+ SYNTAX_SALT : string ;
12
13
R2_BUCKET : R2Bucket ;
13
14
R2_ASSETS : R2Bucket ;
14
15
}
You can’t perform that action at this time.
0 commit comments