Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paraglide-sveltekit: Fix constants #3184

Merged
merged 5 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]

## 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)
})
})
Loading