Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function platformRouter (platform) {
const { configXml, www } = platforms.getPlatformApi(platform).getPlatformInfo().locations;
const router = cordovaServe.Router();
router.use('/www', cordovaServe.static(www));
router.get('/config.xml', (req, res) => res.sendFile(configXml));
router.get('/project.json', (req, res) => res.send({
configPath: `/${platform}/config.xml`,
wwwPath: `/${platform}/www`,
wwwFileList: generateWwwFileList(www)
}));
return router;
}
beforeEach(() => {
spyOn(cordovaUtil, 'listPlatforms').and.returnValue(['foo']);
serve.__set__({
handleRoot: jasmine.createSpy('handleRoot'),
absolutePathHandler: jasmine.createSpy('absolutePathHandler'),
platformRouter: jasmine.createSpy('platformRouter')
.and.returnValue(_ => _)
});
registerRoutes = serve.__get__('registerRoutes');
app = new cordovaServe.Router();
});
function platformRouter (platform) {
const { configXml, www } = platforms.getPlatformApi(platform).getPlatformInfo().locations;
const router = cordovaServe.Router();
router.use('/www', cordovaServe.static(www));
router.get('/config.xml', (req, res) => res.sendFile(configXml));
router.get('/project.json', (req, res) => res.send({
configPath: `/${platform}/config.xml`,
wwwPath: `/${platform}/www`,
wwwFileList: generateWwwFileList(www)
}));
return router;
}
installedPlatforms.forEach(function (platform) {
var locations = platforms.getPlatformApi(platform).getPlatformInfo().locations;
server.app.use('/' + platform + '/www', serve.static(locations.www));
server.app.get('/' + platform + '/*', getPlatformHandler(platform, locations.www, locations.configXml));
});