-
Notifications
You must be signed in to change notification settings - Fork 2.3k
url-helper.ts now leverages well-known environment variables.
#1941
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
Merged
+141
−23
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e8e8219
`utl-helper.ts` now leverages well-known environment variables.
jww3 df4b58c
second attempt
jww3 2f42443
restore passing `baseUrl` where appropriate
jww3 7fcbcdc
ran `npm run format`
jww3 19060a1
ran `npm run build`
jww3 813c3f2
Apply suggestions from @easyt
jww3 041723a
updated unit tests
jww3 914445f
Responded to PR feedback.
jww3 7695871
ran `npm run build`
jww3 7fd13ec
Address `hasContent` readability
jww3 55f79d9
Use concise `WhitespaceMode` names
jww3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import * as urlHelper from '../src/url-helper' | ||
|
|
||
| describe('getServerUrl tests', () => { | ||
| it('basics', async () => { | ||
| // Note that URL::toString will append a trailing / when passed just a domain name ... | ||
| expect(urlHelper.getServerUrl().toString()).toBe('https://github.com/') | ||
| expect(urlHelper.getServerUrl(' ').toString()).toBe('https://github.com/') | ||
| expect(urlHelper.getServerUrl(' ').toString()).toBe('https://github.com/') | ||
| expect(urlHelper.getServerUrl('http://contoso.com').toString()).toBe( | ||
| 'http://contoso.com/' | ||
| ) | ||
| expect(urlHelper.getServerUrl('https://contoso.com').toString()).toBe( | ||
| 'https://contoso.com/' | ||
| ) | ||
| expect(urlHelper.getServerUrl('https://contoso.com/').toString()).toBe( | ||
| 'https://contoso.com/' | ||
| ) | ||
|
|
||
| // ... but can't make that same assumption when passed an URL that includes some deeper path. | ||
| expect(urlHelper.getServerUrl('https://contoso.com/a/b').toString()).toBe( | ||
| 'https://contoso.com/a/b' | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('isGhes tests', () => { | ||
| it('basics', async () => { | ||
| expect(urlHelper.isGhes()).toBeFalsy() | ||
| expect(urlHelper.isGhes('https://github.com')).toBeFalsy() | ||
| expect(urlHelper.isGhes('https://contoso.ghe.com')).toBeFalsy() | ||
| expect(urlHelper.isGhes('https://test.github.localhost')).toBeFalsy() | ||
| expect(urlHelper.isGhes('https://src.onpremise.fabrikam.com')).toBeTruthy() | ||
| }) | ||
| }) | ||
|
|
||
| describe('getServerApiUrl tests', () => { | ||
| it('basics', async () => { | ||
| expect(urlHelper.getServerApiUrl()).toBe('https://api.github.com') | ||
| expect(urlHelper.getServerApiUrl('https://github.com')).toBe( | ||
| 'https://api.github.com' | ||
| ) | ||
| expect(urlHelper.getServerApiUrl('https://GitHub.com')).toBe( | ||
| 'https://api.github.com' | ||
| ) | ||
| expect(urlHelper.getServerApiUrl('https://contoso.ghe.com')).toBe( | ||
| 'https://api.contoso.ghe.com' | ||
| ) | ||
| expect(urlHelper.getServerApiUrl('https://fabrikam.GHE.COM')).toBe( | ||
| 'https://api.fabrikam.ghe.com' | ||
| ) | ||
| expect( | ||
| urlHelper.getServerApiUrl('https://src.onpremise.fabrikam.com') | ||
| ).toBe('https://src.onpremise.fabrikam.com/api/v3') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.