microsoft / PowerShellForGitHub

Microsoft PowerShell wrapper for GitHub API
Other
584 stars 184 forks source link

Set-GitHubConfiguration -ApiHostName validation not working #332

Closed rmiroslavov closed 3 years ago

rmiroslavov commented 3 years ago

Expected behavior:

Set-GitHubConfiguration -ApiHostName "https://api.subdomain.domain.com"is getting validated and works

Current behavior

Set-GitHubConfiguration -ApiHostName "https://api.subdomain.domain.com"is getting validated and works throws

Set-GitHubConfiguration : Cannot validate argument on parameter 'ApiHostName'. The argument "https://api.subdomain.domain.com" does not match the "^(?!https?:)(?!api\.)(?!www\.).*" pattern. 
Supply an argument that matches "^(?!https?:)(?!api\.)(?!www\.).*" and try the command again.

While Set-GitHubConfiguration -ApiHostName "ttps://api.subdomain.domain.com" is getting validated

testing on https://regex101.com/ confirm regex validation not working as intended

No match image

Returns match image

Possible solution:

on the regex validation, escape first "h" character

^(?!\https:)(?!api\.)(?!www\.).*

Reproduced using:

$PSVersionTable

Name                           Value                                                                                                                                                          
----                           -----                                                                                                                                                          
PSVersion                      5.1.19041.906                                                                                                                                                  
PSEdition                      Desktop                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                        
BuildVersion                   10.0.19041.906                                                                                                                                                 
CLRVersion                     4.0.30319.42000                                                                                                                                                
WSManStackVersion              3.0                                                                                                                                                            
PSRemotingProtocolVersion      2.3                                                                                                                                                            
SerializationVersion           1.1.0.1                                                                                                                                                        

Windows 10
PowerShell ISE
rmiroslavov commented 3 years ago

Neverming, It works without prefixing "https://" or "api". Closing this.

HowardWolosky commented 3 years ago

Correct. As documented:

https://github.com/microsoft/PowerShellForGitHub/blob/0ebf9e8b8d0f4fa361996674dbca804da36bace7/GitHubConfiguration.ps1#L69-L72

https://github.com/microsoft/PowerShellForGitHub/blob/0ebf9e8b8d0f4fa361996674dbca804da36bace7/GitHubConfiguration.ps1#L197-L201

Although maybe we need to consider just taking in whatever the input is and removing the part that we don't want, in order to be more user friendly....