Skip to content

Commit

Permalink
fix(sanitizeFilePath): remove query string (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 9, 2023
1 parent fec9c66 commit 203676a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/utils.ts
Expand Up @@ -21,6 +21,7 @@ export function sanitizeURIComponent(name = "", replacement = "_"): string {

export function sanitizeFilePath(filePath = "") {
return filePath
.replace(/\?.*$/, "") // remove query string
.split(/[/\\]/g)
.map((p) => sanitizeURIComponent(p))
.join("/")
Expand Down
5 changes: 3 additions & 2 deletions test/utils.test.ts
Expand Up @@ -28,9 +28,10 @@ describe("sanitizeFilePath", () => {
"C:\\te#st\\[...slug].jsx": "C:/te_st/_...slug_.jsx",
"/te#st/[...slug].jsx": "/te_st/_...slug_.jsx",
"/te#st/[].jsx": "/te_st/_.jsx",
'\0a?b*c:d\u007Fe<f>g#h"i{j}k|l^m[n]o`p.jsx':
'\0a_b*c:d\u007Fe<f>g#h"i{j}k|l^m[n]o`p.jsx':
"_a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p.jsx",
"Foo.vue?vue&type=script&setup=true&generic=T%20extends%20any%2C%20O%20extends%20T%3CZ%7Ca%3E&lang":
"Foo.vue?vue&type=script&setup=true": "Foo.vue",
"Foo.vue&vue&type=script&setup=true&generic=T%20extends%20any%2C%20O%20extends%20T%3CZ%7Ca%3E&lang":
"Foo.vue_vue_type_script_setup_true_generic_T_extends_any__O_extends_T_Z_a__lang",
"": "",
};
Expand Down

0 comments on commit 203676a

Please sign in to comment.