mirror of
				https://github.com/actions/cache.git
				synced 2025-10-31 03:38:36 +08:00 
			
		
		
		
	Encode cache keys
* remove restriction on commas in keys * avoid 404 during save when characters like slashes are used in keys fixes #53
This commit is contained in:
		
							parent
							
								
									f66a56e59e
								
							
						
					
					
						commit
						cda609ee82
					
				|  | @ -17,12 +17,16 @@ async function run() { | ||||||
|         ); |         ); | ||||||
|         core.debug(`Cache Path: ${cachePath}`); |         core.debug(`Cache Path: ${cachePath}`); | ||||||
| 
 | 
 | ||||||
|         const primaryKey = core.getInput(Inputs.Key, { required: true }); |         const keys = [ | ||||||
|  |             core.getInput(Inputs.Key, { required: true }), | ||||||
|  |             ...core | ||||||
|  |                 .getInput(Inputs.RestoreKeys) | ||||||
|  |                 .split(/\s*\n\s*/) | ||||||
|  |                 .filter(x => x) | ||||||
|  |         ].map(key => encodeURIComponent(key).replace(/%/g, " ")); | ||||||
|  |         const primaryKey = keys[0]; | ||||||
|         core.saveState(State.CacheKey, primaryKey); |         core.saveState(State.CacheKey, primaryKey); | ||||||
| 
 | 
 | ||||||
|         const restoreKeys = core.getInput(Inputs.RestoreKeys).split("\n"); |  | ||||||
|         const keys = [primaryKey, ...restoreKeys]; |  | ||||||
| 
 |  | ||||||
|         core.debug("Resolved Keys:"); |         core.debug("Resolved Keys:"); | ||||||
|         core.debug(JSON.stringify(keys)); |         core.debug(JSON.stringify(keys)); | ||||||
| 
 | 
 | ||||||
|  | @ -39,13 +43,6 @@ async function run() { | ||||||
|                 ); |                 ); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|             const regex = /^[^,]*$/; |  | ||||||
|             if (!regex.test(key)) { |  | ||||||
|                 core.setFailed( |  | ||||||
|                     `Key Validation Error: ${key} cannot contain commas.` |  | ||||||
|                 ); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 alexlamsl
						alexlamsl