Skip to content

Commit

Permalink
Merge pull request #3184 from Venmit/parjs-fix-constants
Browse files Browse the repository at this point in the history
paraglide-sveltekit: Fix constants
  • Loading branch information
samuelstroschein authored Oct 22, 2024
2 parents fd6e15e + 4eb9647 commit 7565c0e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
8 changes: 8 additions & 0 deletions inlang/source-code/paraglide/paraglide-sveltekit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @inlang/paraglide-sveltekit

## 0.11.5

### Patch Changes

- bc1e49e: Fixes a silent runtime bug for load functions that depent on paraglide. See https://github.com/opral/monorepo/pull/3184 and https://discord.com/channels/897438559458430986/1297558489182375978/1297645584210985021.

It's a regression bug of `0.11.2` and `0.11.3`.

## 0.11.4

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @inlang/paraglide-sveltekit-example

## 0.1.76

### Patch Changes

- Updated dependencies [bc1e49e]
- @inlang/paraglide-sveltekit@0.11.5

## 0.1.75

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@inlang/paraglide-sveltekit-example",
"version": "0.1.75",
"version": "0.1.76",
"private": true,
"scripts": {
"_dev": "vite dev",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@inlang/paraglide-sveltekit",
"version": "0.11.4",
"version": "0.11.5",
"type": "module",
"main": "./dist/runtime/index.js",
"types": "./dist/runtime/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export const NO_TRANSLATE_ATTRIBUTE = "data-no-translate"

/** The key with which `invalidate` is called when the language changes */
export const LANGUAGE_CHANGE_INVALIDATION_KEY = "paraglide_lang"
export const LANGUAGE_CHANGE_INVALIDATION_KEY = "paraglide:lang"

/** The name of the cookie in which the language is stored */
export const LANG_COOKIE_NAME = "paraglide_lang"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { URL } from "node:url"
import { describe, expect, it } from "vitest"
import * as constants from "./constants"

const DEPENDS_TYPE_REGEX = /^.*:.*$/
// eslint-disable-next-line no-control-regex
const COOKIE_NAME_REGEX = /^((?![()<>@,;:"\\/[\]?={} \x09])[\x20-\x7E])+$/

describe("LANGUAGE_CHANGE_INVALIDATION_KEY", () => {
it("is a valid URL", () => {
expect(() => new URL(constants.LANGUAGE_CHANGE_INVALIDATION_KEY)).not.toThrowError()
})
it("conforms to the type of LoadEvent#depends", () => {
expect(constants.LANGUAGE_CHANGE_INVALIDATION_KEY).toMatch(DEPENDS_TYPE_REGEX)
})
})

describe("LANG_COOKIE_NAME", () => {
it("is a valid cookie name", () => {
expect(constants.LANG_COOKIE_NAME).toMatch(COOKIE_NAME_REGEX)
})
})

0 comments on commit 7565c0e

Please sign in to comment.