Test-ServiceNowURL does not account for URL with a - character
Tuttu opened this issue · 4 comments
Environment
Operating System: Windows 10 1909
ServiceNow module version: v3.0
PowerShell version: 5.1
Steps to reproduce
The URL to access to my ServiceNow instance is quite long and made of multiple part. It also contains a -
character that is not allowed by the RegEx used to test the URL (Yeah, there are really that many part in the URL I need to call).
$SNSession = New-ServiceNowSession -Url 'rct-servicenow.part1.part2.part3.domain.tld' -Credential $Cred
Expected behavior
A new ServiceNow session should be created
Actual behavior
An error message is thrown because the URL is not validated by the RegEx
New-ServiceNowSession : Cannot validate argument on parameter «Url». The expected URL format is tenant.domain.com
Maybe I should change this to Test-ServiceNowURL does not account for URL with a special characters
so that it also includes _, @ and other similar characters?
Hi @Tuttu. Is '.domain.tld' a custom domain or '.service-now.com'? I'm wondering if I can make the assumption that the url will always be 'something.service-now.com'. If so, that would make the regex pretty simple. Otherwise, I'll look to enhance the regex to include special characters.
Hello @gdbarron.
In my case, domain.tld is a local domain and it's not an alias that's pointing to something else. I have to go to rct-servicenow.something.something.something.mydomain.local
for the pre-production environment and to servicenow.something.something.something.mydomain.local
for the production environment.
So if you want to account for all kind of supported characters in a URL (Or at least the most common ones), I guess it's better to change the various \w
by something more complete.
The validation wasn't providing much value so I just removed it.