Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHES support. Allow projects outside github.com #210

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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 src/add-to-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as github from '@actions/github'
// TODO: Ensure this (and the Octokit client) works for non-gh.neting.cc URLs, as well.
// https://github.com/orgs|users/<ownerName>/projects/<projectNumber>
const urlParse =
/^(?:https:\/\/)?github\.com\/(?<ownerType>orgs|users)\/(?<ownerName>[^/]+)\/projects\/(?<projectNumber>\d+)/
/^(?:https:\/\/)?[^/]+\/(?<ownerType>orgs|users)\/(?<ownerName>[^/]+)\/projects\/(?<projectNumber>\d+)/
Copy link
Contributor

@iansan5653 iansan5653 Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (?:https:\/\/)?[^/]+ part of this expression seems like it could be buggy. If the URL protocol is https:// it will work fine, but if it's anything else (like http://), the first group will pass because it's optional and then the [^/] part will unexpectedly stop at the first forward-slash, which will be in the protocol.

Maybe we shouldn't have a 'beginning-of-string' part of the regex at all? It doesn't seem to really matter what goes before or after the part of the URL we care about. That seems like it would allow us to make a more robust regex that just searches anywhere in the string for a /orgs/*/projects/* match:

\/(?<ownerType>orgs|users)\/(?<ownerName>[^/]+)\/projects\/(?<projectNumber>\d+)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iansan5653 Anyway I got an answer that this action not working with GHES. But this change will be needed 100% :)

#214

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I forgot the new Projects hasn't shipped to GHES yet 😄

I'm going to close this PR for now but we can revisit & reopen it once that's shipped


interface ProjectNodeIDResponse {
organization?: {
Expand Down