mirror of
				https://github.com/actions/checkout.git
				synced 2025-10-31 10:08:37 +08:00 
			
		
		
		
	ran npm run format
				
					
				
			This commit is contained in:
		
							parent
							
								
									2f42443dda
								
							
						
					
					
						commit
						7fcbcdce7d
					
				|  | @ -14,10 +14,20 @@ describe('isGhes tests', () => { | ||||||
| describe('getServerApiUrl tests', () => { | describe('getServerApiUrl tests', () => { | ||||||
|   it('basics', async () => { |   it('basics', async () => { | ||||||
|     expect(urlHelper.getServerApiUrl()).toBe('https://api.github.com') |     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( | ||||||
|     expect(urlHelper.getServerApiUrl('https://GitHub.com')).toBe('https://api.github.com') |       'https://api.github.com' | ||||||
|     expect(urlHelper.getServerApiUrl('https://europe.ghe.com')).toBe('https://api.europe.ghe.com') |     ) | ||||||
|     expect(urlHelper.getServerApiUrl('https://australia.GHE.COM')).toBe('https://api.australia.ghe.com') |     expect(urlHelper.getServerApiUrl('https://GitHub.com')).toBe( | ||||||
|     expect(urlHelper.getServerApiUrl('https://src.onpremise.customer.com')).toBe('https://src.onpremise.customer.com/api/v3') |       'https://api.github.com' | ||||||
|  |     ) | ||||||
|  |     expect(urlHelper.getServerApiUrl('https://europe.ghe.com')).toBe( | ||||||
|  |       'https://api.europe.ghe.com' | ||||||
|  |     ) | ||||||
|  |     expect(urlHelper.getServerApiUrl('https://australia.GHE.COM')).toBe( | ||||||
|  |       'https://api.australia.ghe.com' | ||||||
|  |     ) | ||||||
|  |     expect( | ||||||
|  |       urlHelper.getServerApiUrl('https://src.onpremise.customer.com') | ||||||
|  |     ).toBe('https://src.onpremise.customer.com/api/v3') | ||||||
|   }) |   }) | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | @ -33,9 +33,9 @@ export function getServerApiUrl(url?: string): string { | ||||||
|   if (hasContent(url, false)) { |   if (hasContent(url, false)) { | ||||||
|     let serverUrl = getServerUrl(url) |     let serverUrl = getServerUrl(url) | ||||||
|     if (isGhes(url)) { |     if (isGhes(url)) { | ||||||
|       serverUrl.pathname = "api/v3" |       serverUrl.pathname = 'api/v3' | ||||||
|     } else { |     } else { | ||||||
|       serverUrl.hostname = "api." + serverUrl.hostname |       serverUrl.hostname = 'api.' + serverUrl.hostname | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return pruneSuffix(serverUrl.toString(), '/') |     return pruneSuffix(serverUrl.toString(), '/') | ||||||
|  | @ -57,7 +57,6 @@ export function isGhes(url?: string): boolean { | ||||||
|   return !isGitHubHost && !isGheHost && !isLocalHost |   return !isGitHubHost && !isGheHost && !isLocalHost | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| function pruneSuffix(text: string, suffix: string) { | function pruneSuffix(text: string, suffix: string) { | ||||||
|   if (hasContent(suffix, true) && text?.endsWith(suffix)) { |   if (hasContent(suffix, true) && text?.endsWith(suffix)) { | ||||||
|     return text.substring(0, text.length - suffix.length) |     return text.substring(0, text.length - suffix.length) | ||||||
|  | @ -65,11 +64,13 @@ function pruneSuffix(text: string, suffix: string) { | ||||||
|   return text |   return text | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function hasContent(text: string | undefined, allowPureWhitespace: boolean): boolean { | function hasContent( | ||||||
|   let refinedText = text ?? "" |   text: string | undefined, | ||||||
|  |   allowPureWhitespace: boolean | ||||||
|  | ): boolean { | ||||||
|  |   let refinedText = text ?? '' | ||||||
|   if (!allowPureWhitespace) { |   if (!allowPureWhitespace) { | ||||||
|     refinedText = refinedText.trim() |     refinedText = refinedText.trim() | ||||||
|   } |   } | ||||||
|   return refinedText.length > 0 |   return refinedText.length > 0 | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 John Wesley Walker III
						John Wesley Walker III