Skip to content

Commit

Permalink
fix: handle uri encoded _path query
Browse files Browse the repository at this point in the history
  • Loading branch information
hannoeru committed Jan 5, 2023
1 parent 30c26e3 commit d528be3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions playground/basic/content/4.slug/こんにちは.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: こんにちは
_path: /slug/こんにちは
---

# 🎨 こんにちは
10 changes: 10 additions & 0 deletions src/runtime/composables/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ export function queryContent<T = ParsedContent> (query?: string | QueryBuilderPa
}
}

// Normalize uri encoded _path in where query
if (params.where) {
params.where = params.where.map((w) => {
if (typeof w._path === 'string') {
w._path = decodeURI(w._path)
}
return w
})
}

return params
}

Expand Down
10 changes: 10 additions & 0 deletions src/runtime/server/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ export function serverQueryContent<T = ParsedContent> (event: H3Event, query?: s
}
}

// Normalize uri encoded _path in where query
if (params.where) {
params.where = params.where.map((w) => {
if (typeof w._path === 'string') {
w._path = decodeURI(w._path)
}
return w
})
}

return params
}

Expand Down

0 comments on commit d528be3

Please sign in to comment.