mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-30 17:37:26 +00:00 
			
		
		
		
	 154fc28a57
			
		
	
	
		154fc28a57
		
	
	
	
	
		
			
			As a result of taking a look on PR #1967 I realized there is 819 executable files in this repository. It is obvious this is an error.
		
			
				
	
	
		
			33 lines
		
	
	
		
			683 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			683 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| /**
 | |
|  * Module dependencies
 | |
|  */
 | |
| 
 | |
| const _ = require('lodash');
 | |
| 
 | |
| /**
 | |
|  * Find controller's location
 | |
|  */
 | |
| 
 | |
| module.exports = (api, controller) => {
 | |
|   if (!_.isObject(api)) {
 | |
|     throw new Error('Should be an object');
 | |
|   }
 | |
| 
 | |
|   if (_.isObject(controller) && controller.hasOwnProperty('identity')) {
 | |
|     controller = controller.identity.toLowerCase();
 | |
|   } else if (_.isString(controller)) {
 | |
|     controller = controller.toLowerCase();
 | |
|   } else {
 | |
|     throw new Error('Should be an object or a string');
 | |
|   }
 | |
| 
 | |
|   const where = _.findKey(api, o => {
 | |
|     return _.get(o, `controllers.${controller}`);
 | |
|   });
 | |
| 
 | |
|   // Return the API's name where the controller is located
 | |
|   return where;
 | |
| };
 |