Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
074538e
feat: add `removeHtmlExtension` option
azat-io Dec 30, 2024
a94ae62
fix: improve assets path resolution for static pages
rafalynch Mar 28, 2025
46b85b5
fix: correct resource path resolution logic
rafalynch Mar 28, 2025
25cf2cf
Merge pull request #1 from rafalynch/main
smithcoin Apr 28, 2025
57f5ee5
Merge pull request #2 from azat-io/feat/remove-html-ext
smithcoin Apr 28, 2025
fdc5872
update deps
smithcoin Apr 28, 2025
f0389a4
bump version
smithcoin Apr 28, 2025
e46401b
Merge pull request #3 from digitalmint/update-deps
smithcoin Apr 28, 2025
b05d79a
bump versions
smithcoin Apr 28, 2025
753fbec
bump versions
smithcoin Apr 28, 2025
57196dc
Merge pull request #4 from digitalmint/upgrade-deps
smithcoin Apr 28, 2025
69228f4
bump versions
smithcoin Apr 28, 2025
b5d4994
Merge pull request #8 from digitalmint/recursive-update
smithcoin Apr 28, 2025
ae0e3f0
chore(deps-dev): bump vite in the dev-deps-security group
dependabot[bot] Apr 30, 2025
b71f2dc
Merge pull request #9 from digitalmint/dependabot/npm_and_yarn/dev-de…
smithcoin May 8, 2025
c38836c
chore(deps-dev): bump the dev-deps group across 1 directory with 7 up…
dependabot[bot] May 8, 2025
63761ab
Merge pull request #12 from digitalmint/dependabot/npm_and_yarn/dev-d…
smithcoin May 8, 2025
9154a38
chore(deps): bump the prod-deps group with 3 updates
dependabot[bot] May 19, 2025
1aed17a
chore(deps-dev): bump the dev-deps group across 1 directory with 3 up…
dependabot[bot] May 19, 2025
597d4b3
Merge pull request #14 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin May 19, 2025
d03d3cd
Merge branch 'main' into dependabot/npm_and_yarn/dev-deps-65856f17b0
smithcoin May 19, 2025
e531ebf
Merge pull request #15 from digitalmint/dependabot/npm_and_yarn/dev-d…
smithcoin May 19, 2025
5d74678
chore(deps): bump the prod-deps group with 4 updates
dependabot[bot] May 26, 2025
99aa971
Merge pull request #17 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin Jun 23, 2025
f1041a8
chore(deps-dev): bump the dev-deps group across 1 directory with 8 up…
dependabot[bot] Jun 30, 2025
0fb65fa
Merge pull request #22 from digitalmint/dependabot/npm_and_yarn/dev-d…
smithcoin Jul 14, 2025
2e62274
chore(deps-dev): bump the dev-deps group with 6 updates
dependabot[bot] Jul 21, 2025
cb13ecf
chore(deps): bump the prod-deps group with 4 updates
dependabot[bot] Jul 21, 2025
8151599
Merge pull request #26 from digitalmint/dependabot/npm_and_yarn/dev-d…
smithcoin Jul 22, 2025
af6e70b
Merge branch 'main' into dependabot/npm_and_yarn/prod-deps-61f71098e3
smithcoin Jul 22, 2025
6919792
Merge pull request #27 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin Jul 22, 2025
24be3bb
chore(deps): bump the prod-deps group across 1 directory with 2 updates
dependabot[bot] Jul 22, 2025
027b58e
Merge pull request #28 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin Jul 22, 2025
4b7beff
pnpm update recursive
smithcoin Jul 23, 2025
c195755
Merge pull request #29 from digitalmint/deps
smithcoin Jul 23, 2025
0519d07
chore(deps): bump astro in the prod-deps-security group
dependabot[bot] Aug 7, 2025
13ca59c
Merge pull request #33 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin Aug 7, 2025
6e14dd5
chore(deps): bump the prod-deps group with 2 updates
dependabot[bot] Aug 11, 2025
1e28796
Merge pull request #35 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin Aug 18, 2025
8683456
chore(deps): bump @astrojs/node in the prod-deps-security group
dependabot[bot] Aug 18, 2025
a673e6e
Merge pull request #37 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin Aug 18, 2025
3f4726b
chore(deps): bump the prod-deps group across 1 directory with 3 updates
dependabot[bot] Sep 8, 2025
ef6294f
Merge pull request #42 from digitalmint/dependabot/npm_and_yarn/prod-…
smithcoin Sep 11, 2025
141d3c6
chore(deps-dev): bump vite
dependabot[bot] Sep 11, 2025
fde3825
Merge pull request #44 from digitalmint/dependabot/npm_and_yarn/dev-d…
smithcoin Sep 11, 2025
b033596
chore(deps-dev): bump @astrojs/starlight
dependabot[bot] Sep 11, 2025
c4683bb
Merge pull request #46 from digitalmint/dependabot/npm_and_yarn/dev-d…
smithcoin Sep 11, 2025
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
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.9.0
22.15.0
26 changes: 14 additions & 12 deletions @kindspells/astro-shield/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kindspells/astro-shield",
"version": "1.7.1",
"version": "1.8.0",
"description": "Astro integration to enhance your website's security with SubResource Integrity hashes, Content-Security-Policy headers, and other techniques.",
"private": false,
"type": "module",
Expand All @@ -27,7 +27,9 @@
"import": "./dist/*.mjs"
}
},
"files": ["dist/*"],
"files": [
"dist/*"
],
"scripts": {
"build": "moon run build",
"format": "biome format --write .",
Expand Down Expand Up @@ -63,15 +65,15 @@
"astro": "^4.0.0"
},
"devDependencies": {
"@types/node": "^22.8.6",
"astro": "^4.16.8",
"get-tsconfig": "^4.8.1",
"rollup": "^4.24.3",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"typescript": "^5.6.3",
"vite": "^5.4.10",
"vitest": "^2.1.4"
"@types/node": "^22.16.5",
"astro": "^5.12.9",
"get-tsconfig": "^4.10.1",
"rollup": "^4.45.1",
"rollup-plugin-dts": "^6.2.1",
"rollup-plugin-esbuild": "^6.2.1",
"typescript": "^5.8.3",
"vite": "^7.1.5",
"vitest": "^3.2.4"
},
"repository": {
"type": "git",
Expand All @@ -89,7 +91,7 @@
"url": "https://ko-fi.com/coderspirit"
}
],
"packageManager": "pnpm@9.11.0",
"packageManager": "pnpm@10.10.0",
"engines": {
"node": ">= 18.0.0"
},
Expand Down
8 changes: 7 additions & 1 deletion @kindspells/astro-shield/src/core.mts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,13 @@ export const updateStaticPageSriHashes = async (
const updatedSrc = src.startsWith(base)
? src.replace(base, '')
: src
const resourcePath = resolve(distDir, `.${updatedSrc}`)

// Prepare a relative path for resolve - depending on a trailing slash on base above
// after removing it, updatedSrc may or may not start with a slash
const resourcePath = resolve(
distDir,
updatedSrc.startsWith('/') ? `.${updatedSrc}` : updatedSrc,
)
resourceContent = await readFile(resourcePath)
} else {
// TODO: should we remove the element?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"license": "MIT",
"dependencies": {
"@astrojs/node": "^8.3.4",
"astro": "^4.16.8"
"@astrojs/node": "^9.4.1",
"astro": "^5.12.9"
},
"devDependencies": {
"@kindspells/astro-shield": "workspace:*"
Expand Down
4 changes: 2 additions & 2 deletions @kindspells/astro-shield/src/e2e/fixtures/hybrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"license": "MIT",
"dependencies": {
"@astrojs/node": "^8.3.4",
"astro": "^4.16.8"
"@astrojs/node": "^9.4.1",
"astro": "^5.12.9"
},
"devDependencies": {
"@kindspells/astro-shield": "workspace:*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"license": "MIT",
"dependencies": {
"@astrojs/node": "^8.3.4",
"astro": "^4.16.8"
"@astrojs/node": "^9.4.1",
"astro": "^5.12.9"
},
"devDependencies": {
"@kindspells/astro-shield": "workspace:*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"license": "MIT",
"dependencies": {
"@astrojs/node": "^8.3.4",
"astro": "^4.16.8"
"@astrojs/node": "^9.4.1",
"astro": "^5.12.9"
},
"devDependencies": {
"@kindspells/astro-shield": "workspace:*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"license": "MIT",
"dependencies": {
"astro": "^4.16.8"
"astro": "^5.12.9"
},
"devDependencies": {
"@kindspells/astro-shield": "workspace:*"
Expand Down
8 changes: 8 additions & 0 deletions @kindspells/astro-shield/src/netlify.mts
Original file line number Diff line number Diff line change
Expand Up @@ -459,5 +459,13 @@ export const patchNetlifyHeadersConfig = async (

const mergedConfig = mergeNetlifyHeadersConfig(baseConfig, patchConfig)

if (securityHeadersOptions.removeHtmlExtension) {
for (const entry of mergedConfig.entries) {
if (typeof entry === 'object' && 'path' in entry) {
entry.path = entry.path.replace(/\.html$/, '')
}
}
}

await writeFile(configPath, serializeNetlifyHeadersConfig(mergedConfig))
}
7 changes: 7 additions & 0 deletions @kindspells/astro-shield/src/types.mts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ export type SecurityHeadersOptions = {
* Defaults to `undefined`.
*/
contentSecurityPolicy?: CSPOptions | undefined

/**
* - If set, it will remove the `.html` extension from the URLs.
*
* Defaults to `false`.
*/
removeHtmlExtension?: boolean
}

export type ShieldOptions = {
Expand Down
7 changes: 7 additions & 0 deletions @kindspells/astro-shield/src/vercel.mts
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,12 @@ export const patchVercelHeadersConfig = async (

const mergedConfig = mergeVercelConfig(baseConfig, patchConfig)

if (securityHeadersOptions.removeHtmlExtension) {
for (const route of mergedConfig.routes ?? []) {
if (route.src.endsWith('.html'))
route.src = route.src.slice(0, -5)
}
}

await writeFile(configPath, serializeVercelConfig(mergedConfig))
}
12 changes: 6 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
"start": "astro dev"
},
"dependencies": {
"astro-sst": "^2.43.5",
"sharp": "0.33.5",
"sst": "^3.2.73"
"astro-sst": "^3.1.4",
"sharp": "0.34.3",
"sst": "^3.17.12"
},
"devDependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/starlight": "^0.28.5",
"@astrojs/starlight": "^0.35.2",
"@astrojs/ts-plugin": "^1.10.4",
"@kindspells/astro-shield": "workspace:^",
"astro": "^4.16.8",
"typescript": "^5.6.3"
"astro": "^5.12.9",
"typescript": "^5.8.3"
}
}
6 changes: 6 additions & 0 deletions docs/src/content/docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,9 @@ Type: `object | undefined`, defaults to `undefined`.

Possible values are:
- `'netlify'`: Generate the security headers for static content on Netlify.

#### `securityHeaders.removeHtmlExtension`

If set, it will remove the `.html` extension from the URLs.

Type: `boolean`, defaults to `false`.
9 changes: 8 additions & 1 deletion docs/src/content/docs/ru/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Content-Security-Policy (CSP) для динамического контента

### `sri.hashesModule`

Указывает путь к автоматически сгенерированному модулю, который содержит и
Указывает путь к автоматически сгенерированному модулю, который содержит и
кспортирует хеши SRI, вычисленные Astro-Shield для нашего контента.

Мы можем импортировать этот модуль в наш собственный код, если нам нужно
Expand Down Expand Up @@ -201,3 +201,10 @@ Content-Security-Policy (CSP) для статического и/или дина

Возможные значения:
- `'netlify'`: генерировать заголовки безопасности для статического контента на Netlify.

#### `securityHeaders.removeHtmlExtension`

Если установлено, то Astro-Shield будет удалять расширение `.html` из
URL-адресов.

Тип: `boolean`, defaults to `false`.
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kindspells/root",
"private": true,
"version": "1.0.0",
"version": "1.0.2",
"license": "MIT",
"contributors": [
{
Expand All @@ -10,21 +10,23 @@
}
],
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@moonrepo/cli": "^1.29.3",
"@vitest/coverage-v8": "^2.1.4",
"publint": "^0.2.12",
"vitest": "^2.1.4"
"@biomejs/biome": "^2.1.2",
"@moonrepo/cli": "^1.38.6",
"@vitest/coverage-v8": "^3.2.4",
"publint": "^0.3.12",
"vitest": "^3.2.4"
},
"engines": {
"node": ">= 22.9.0"
},
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@10.10.0",
"scripts": {
"format": "biome format --write .",
"install-githooks": "if [ -d .git ]; then git config core.hooksPath .hooks; fi"
},
"pnpm": {
"onlyBuiltDependencies": ["@moonrepo/cli"]
"onlyBuiltDependencies": [
"@moonrepo/cli"
]
}
}
Loading