Skip to content

Commit 335f855

Browse files
committed
fix(framework-configuration): getExt return invalid extension when relative path is supplied
1 parent a3552ed commit 335f855

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/framework-configuration.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {join} from 'aurelia-path';
55
import {Container} from 'aurelia-dependency-injection';
66

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

910
function runTasks(config, tasks) {
1011
let current;
@@ -89,18 +90,21 @@ function loadResources(aurelia, resourcesToLoad, appResources) {
8990
}
9091

9192
function removeExt(name) {
92-
return name.replace(/\.[^/.]+$/, '');
93-
}
94-
95-
function getExt(name) {
96-
return name.split('.')[1];
93+
return name.replace(extPattern, '');
9794
}
9895

9996
function addOriginalExt(normalized, ext) {
10097
return removeExt(normalized) + '.' + ext;
10198
}
10299
}
103100

101+
function getExt(name) {
102+
let match = name.match(extPattern);
103+
if (match && match.length > 0) {
104+
return (match[0].split('.'))[1];
105+
}
106+
}
107+
104108
function assertProcessed(plugins) {
105109
if (plugins.processed) {
106110
throw new Error('This config instance has already been applied. To load more plugins or global resources, create a new FrameworkConfiguration instance.');
@@ -199,15 +203,11 @@ export class FrameworkConfiguration {
199203
* @return Returns the current FrameworkConfiguration instance.
200204
*/
201205
feature(plugin: string, config?: any): FrameworkConfiguration {
202-
if (hasExt(plugin)) {
206+
if (getExt(plugin)) {
203207
return this.plugin({ moduleId: plugin, resourcesRelativeTo: [plugin, ''], config: config || {} });
204208
}
205209

206210
return this.plugin({ moduleId: plugin + '/index', resourcesRelativeTo: [plugin, ''], config: config || {} });
207-
208-
function hasExt(name) {
209-
return (name.split('.')).length > 1;
210-
}
211211
}
212212

213213
/**

0 commit comments

Comments
 (0)