Skip to content

Commit

Permalink
Merge pull request #1689 from googlefonts/lang-cache-bust-issue-1655
Browse files Browse the repository at this point in the history
Make json paths used in js file use the cache busting version token
  • Loading branch information
justvanrossum authored Oct 1, 2024
2 parents 021ef65 + 1a48dca commit 190b42e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/fontra/client/core/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const ensureLanguageHasLoaded = new Promise((resolve) => {
});

function languageChanged(locale) {
fetchJSON(`/lang/${locale}.json`).then((data) => {
// Do explicit .replace() because our cache busting mechanism is simplistic,
// and backtick strings don't work.
const translationsPath = "/lang/locale.json".replace("locale", locale);
fetchJSON(translationsPath).then((data) => {
localizationData = data;
resolveLanguageHasLoaded();
});
Expand Down
2 changes: 1 addition & 1 deletion src/fontra/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async def viewPathHandler(
def _addVersionTokenToReferences(self, data: bytes, contentType: str) -> bytes:
if self.versionToken is None:
return data
jsAllowedFileExtensions = ["css", "js", "svg"]
jsAllowedFileExtensions = ["css", "js", "svg", "json"]
extensionMapping = {
"text/html": self.allowedFileExtensions,
"text/css": ["woff2", "svg"],
Expand Down

0 comments on commit 190b42e

Please sign in to comment.