Skip to content

Commit

Permalink
Updated beacon
Browse files Browse the repository at this point in the history
  • Loading branch information
jeawhanlee committed Mar 4, 2025
1 parent d63eb09 commit 0a5fcff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions assets/js/wpr-beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@
getFontFaceRules() {
const stylesheetFonts = {};
Array.from(document.styleSheets).forEach((sheet) => {
if (sheet.href && new URL(sheet.href).origin !== window.location.origin) return;
try {
Array.from(sheet.cssRules || []).forEach((rule) => {
if (rule instanceof CSSFontFaceRule) {
Expand All @@ -475,9 +474,11 @@
}
const urls = src.match(/url\(['"]?([^'"]+)['"]?\)/g) || [];
urls.forEach((urlMatch) => {
const rawUrl = urlMatch.match(/url\(['"]?([^'"]+)['"]?\)/)[1];
const url = new URL(rawUrl, sheet.href).href;
const normalizedUrl = this.cleanUrl(url);
let rawUrl = urlMatch.match(/url\(['"]?([^'"]+)['"]?\)/)[1];
if (sheet.href) {
rawUrl = new URL(rawUrl, sheet.href).href;
}
const normalizedUrl = this.cleanUrl(rawUrl);
if (!stylesheetFonts[fontFamily].urls.includes(normalizedUrl)) {
stylesheetFonts[fontFamily].urls.push(normalizedUrl);
stylesheetFonts[fontFamily].variations.add(JSON.stringify({
Expand Down Expand Up @@ -520,6 +521,7 @@
* @returns {Promise<void>} A promise that resolves when the analysis is complete.
*/
async run() {
await document.fonts.ready;
const networkLoadedFonts = this.getNetworkLoadedFonts();
const stylesheetFonts = this.getFontFaceRules();
const hostedFonts = /* @__PURE__ */ new Map();
Expand Down
Loading

0 comments on commit 0a5fcff

Please sign in to comment.