Skip to content

Commit

Permalink
fix: handle owner but no name syntax (#2045)
Browse files Browse the repository at this point in the history
  • Loading branch information
f0ssel committed Jun 6, 2022
1 parent 77d0682 commit 3be3bc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions site/src/util/workspace.test.ts
Expand Up @@ -71,6 +71,7 @@ describe("util > workspace", () => {
["owner:me", { owner: "me" }],
["owner:me owner:me2", { owner: "me" }],
["me/dev", { owner: "me", name: "dev" }],
["me/", { owner: "me" }],
[" key:val owner:me ", { owner: "me" }],
])(`query=%p, filter=%p`, (query, filter) => {
expect(workspaceQueryToFilter(query)).toEqual(filter)
Expand Down
23 changes: 13 additions & 10 deletions site/src/util/workspace.ts
Expand Up @@ -218,24 +218,27 @@ export const workspaceQueryToFilter = (query?: string): TypesGen.WorkspaceFilter
const parts = preparedQuery.split(" ")

for (const part of parts) {
const [key, val] = part.split(":")
if (key && val) {
if (key === "owner") {
return {
owner: val,
if (part.includes(":")) {
const [key, val] = part.split(":")
if (key && val) {
if (key === "owner") {
return {
owner: val,
}
}
// skip invalid key pairs
continue
}
// skip invalid key pairs
continue
}

const [username, name] = part.split("/")
if (username && name) {
if (part.includes("/")) {
const [username, name] = part.split("/")
return {
owner: username,
name: name,
name: name === "" ? undefined : name,
}
}

return {
name: part,
}
Expand Down

0 comments on commit 3be3bc2

Please sign in to comment.