Skip to content

Commit

Permalink
add forwarded host, avoid mutating const
Browse files Browse the repository at this point in the history
  • Loading branch information
maxakuru committed Aug 15, 2024
1 parent 26c5878 commit a93a294
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
19 changes: 11 additions & 8 deletions tools/cache/debugger.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ input#url-input {
}

.tile {
box-shadow: 3px 3px 4px rgba(0 0 0 10%);
box-shadow: 3px 3px 4px rgba(0 0 0 0.1);
border-radius: 8px;
margin: 12px 0;
padding: 12px 0;
Expand All @@ -47,12 +47,16 @@ div.row span.val.bad {

.pill {
border-radius: 20px;
padding: 4px 8px;
margin: 0 4px;
font-size: 0.8em;
border: 1px solid #000;
white-space: nowrap;
line-height: 2.2;
padding: 4px 8px;
margin: 0 4px;
font-size: 0.8em;
border: 1px solid #000;
white-space: nowrap;
line-height: 2.2;
}

.pill.badge {
margin-left: -2px;
}

.pill.good {
Expand All @@ -70,5 +74,4 @@ div.row span.val.bad {
.pill.warn {
background-color: #FFA500;
border: 1px solid #FFA500;

}
22 changes: 14 additions & 8 deletions tools/cache/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ const tileTemplate = (
</div>
${
Object.entries(ENV_HEADERS[env]).map(([key, valKeys]) => {
if (typeof valKeys === 'string') {
// eslint-disable-next-line no-param-reassign
valKeys = [valKeys];
}
// eslint-disable-next-line no-param-reassign
valKeys = typeof valKeys === 'string' ? [valKeys] : [...valKeys];
let valCls = '';
let val = '';
while (!val && valKeys.length) {
Expand Down Expand Up @@ -101,10 +100,11 @@ const renderDetails = (data) => {
const {
x_push_invalidation: pushInval = 'disabled',
x_byo_cdn_type: byoCdnType = 'unknown',
x_forwarded_host: forwardedHost = '',
} = data.probe.req.headers;
const pushInvalPill = pushInval === 'enabled'
? '<span class="pill good">enabled</span>'
: '<span class="pill bad">disabled</span>';
? '<span class="pill badge good">enabled</span>'
: '<span class="pill badge bad">disabled</span>';
const actualCdn = inferCDNType(data);
const cdnMatchClass = actualCdn === byoCdnType ? 'good' : 'bad';

Expand All @@ -118,11 +118,15 @@ const renderDetails = (data) => {
</div>
<div class="row">
<span class="key">BYOCDN Type</span>
<span class="val"><span class="pill ${cdnMatchClass}">${byoCdnType}</span></span>
<span class="val"><span class="pill badge ${cdnMatchClass}">${byoCdnType}</span></span>
</div>
<div class="row">
<span class="key">Actual CDN Type</span>
<span class="val"><span class="pill ${cdnMatchClass}">${actualCdn}</span></span>
<span class="val"><span class="pill badge ${cdnMatchClass}">${actualCdn}</span></span>
</div>
<div class="row">
<span class="key">Forwarded Host</span>
<span class="val">${forwardedHost}</span>
</div>
</div>
`;
Expand All @@ -146,6 +150,8 @@ const renderDetails = (data) => {
};

(async () => {
// renderDetails(stub);

const loc = new URL(window.location.href);
if (loc.searchParams.has('url')) {
input.value = loc.searchParams.get('url');
Expand Down

0 comments on commit a93a294

Please sign in to comment.