Skip to content

Commit

Permalink
fix(framework-configuration): getExt return invalid extension when re…
Browse files Browse the repository at this point in the history
…lative path is supplied
  • Loading branch information
ahmedshuhel committed Mar 26, 2016
1 parent a3552ed commit 335f855
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/framework-configuration.js
Expand Up @@ -5,6 +5,7 @@ import {join} from 'aurelia-path';
import {Container} from 'aurelia-dependency-injection';

const logger = TheLogManager.getLogger('aurelia');
const extPattern = /\.[^/.]+$/;

function runTasks(config, tasks) {
let current;
Expand Down Expand Up @@ -89,18 +90,21 @@ function loadResources(aurelia, resourcesToLoad, appResources) {
}

function removeExt(name) {
return name.replace(/\.[^/.]+$/, '');
}

function getExt(name) {
return name.split('.')[1];
return name.replace(extPattern, '');
}

function addOriginalExt(normalized, ext) {
return removeExt(normalized) + '.' + ext;
}
}

function getExt(name) {
let match = name.match(extPattern);
if (match && match.length > 0) {
return (match[0].split('.'))[1];
}
}

function assertProcessed(plugins) {
if (plugins.processed) {
throw new Error('This config instance has already been applied. To load more plugins or global resources, create a new FrameworkConfiguration instance.');
Expand Down Expand Up @@ -199,15 +203,11 @@ export class FrameworkConfiguration {
* @return Returns the current FrameworkConfiguration instance.
*/
feature(plugin: string, config?: any): FrameworkConfiguration {
if (hasExt(plugin)) {
if (getExt(plugin)) {
return this.plugin({ moduleId: plugin, resourcesRelativeTo: [plugin, ''], config: config || {} });
}

return this.plugin({ moduleId: plugin + '/index', resourcesRelativeTo: [plugin, ''], config: config || {} });

function hasExt(name) {
return (name.split('.')).length > 1;
}
}

/**
Expand Down

0 comments on commit 335f855

Please sign in to comment.