Repository: pwntester/octo.nvim (lua)

Issue:
`Octo <discussion-url>` does work

This works for PRs and Issues so it should work for discussions

Pull request description:
<!--  Thanks for submitting a pull request! Here are some tips for you:
1. Please make sure you have read and understood the contributing guidelines: https://github.com/pwntester/octo.nvim/blob/master/CONTRIBUTING.md
2. Please make sure the PR has a corresponding issue.
-->

### Describe what this PR does / why we need it

Octo <discussion-url> now works


### Does this pull request fix one issue?

<!--If that, add "Fixes #xxxx" below in the next line. For example, Fixes #15. Otherwise, add "NONE" -->

### Describe how you did it

- **adjust the regex**
- **branch when discussion**
- **add some tests**


### Describe how to verify it


### Special notes for reviews

### Checklist

- [ ] Passing tests and linting standards
- [ ] Documentation updates in README.md and doc/octo.txt

Patch:
diff --git a/lua/octo/commands.lua b/lua/octo/commands.lua
index c80b75a46..2bd956d58 100644
--- a/lua/octo/commands.lua
+++ b/lua/octo/commands.lua
@@ -821,6 +821,8 @@ function M.octo(object, action, ...)
       utils.get_issue(number, repo)
     elseif repo and number and kind == "pull" then
       utils.get_pull_request(number, repo)
+    elseif repo and number and kind == "discussion" then
+      utils.get_discussion(number, repo)
     else
       utils.error("Incorrect argument: " .. object)
       return
diff --git a/lua/octo/constants.lua b/lua/octo/constants.lua
index 241bbb5a6..74df0f871 100644
--- a/lua/octo/constants.lua
+++ b/lua/octo/constants.lua
@@ -24,7 +24,7 @@ M.NO_BODY_MSG = "No description provided."
 M.LONG_ISSUE_PATTERN = "([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)#(%d+)"
 M.SHORT_ISSUE_PATTERN = "[^%w%d]+#(%d+)"
 M.SHORT_ISSUE_LINE_BEGINNING_PATTERN = "^#(%d+)"
-M.URL_ISSUE_PATTERN = "[htps]+://[^/]+/([^/]+/[^/]+)/([pulisue]+)/(%d+)"
+M.URL_ISSUE_PATTERN = "[htps]+://[^/]+/([^/]+/[^/]+)/([pulisedcton]+)/(%d+)"
 
 M.USER_PATTERN = "@([%w-]+)"
 
diff --git a/lua/octo/utils.lua b/lua/octo/utils.lua
index 52d8aeb2d..e8f0ddc2e 100644
--- a/lua/octo/utils.lua
+++ b/lua/octo/utils.lua
@@ -924,6 +924,8 @@ function M.parse_url(url)
     return repo, number, "issue"
   elseif repo and number and kind == "pull" then
     return repo, number, kind
+  elseif repo and number and kind == "discussions" then
+    return repo, number, "discussion"
   end
 end
 


Test patch:
diff --git a/lua/tests/plenary/utils_spec.lua b/lua/tests/plenary/utils_spec.lua
index 106ce6918..10ceed8a1 100644
--- a/lua/tests/plenary/utils_spec.lua
+++ b/lua/tests/plenary/utils_spec.lua
@@ -164,3 +164,29 @@ describe("get_flatten_pages", function()
     eq(actual, { { a = 1 }, { b = 2, name = "foo" }, { c = 3 }, { d = 4 } })
   end)
 end)
+describe("parse_url", function()
+  it("issues", function()
+    local url = "https://github.com/pwntester/octo.nvim/issues/1"
+    local repo, number, kind = this.parse_url(url)
+
+    eq(repo, "pwntester/octo.nvim")
+    eq(number, "1")
+    eq(kind, "issue")
+  end)
+  it("pull", function()
+    local url = "https://github.com/pwntester/octo.nvim/pull/1"
+    local repo, number, kind = this.parse_url(url)
+
+    eq(repo, "pwntester/octo.nvim")
+    eq(number, "1")
+    eq(kind, "pull")
+  end)
+  it("discussion", function()
+    local url = "https://github.com/pwntester/octo.nvim/discussions/1"
+    local repo, number, kind = this.parse_url(url)
+
+    eq(repo, "pwntester/octo.nvim")
+    eq(number, "1")
+    eq(kind, "discussion")
+  end)
+end)