From 86afdd8c76192b0adcfb670482ff9ee8f40d7a03 Mon Sep 17 00:00:00 2001 From: Jeremy Danyow Date: Mon, 28 Mar 2016 10:25:07 -0400 Subject: [PATCH] fix(html-resource-plugin): handle query string and mixed casing Fixes #203 --- src/html-resource-plugin.js | 8 +------- test/html-resource-plugin.spec.js | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/html-resource-plugin.js b/src/html-resource-plugin.js index e900f1b..34abee3 100644 --- a/src/html-resource-plugin.js +++ b/src/html-resource-plugin.js @@ -2,13 +2,7 @@ import {ViewEngine} from 'aurelia-templating'; import {_createDynamicElement} from './dynamic-element'; export function getElementName(address) { - let elementName = address.replace('.html', ''); - let index = elementName.lastIndexOf('/'); - - if (index !== 0) { - elementName = elementName.substring(index + 1); - } - return elementName; + return /([^\/^\?]+)\.html/i.exec(address)[1].toLowerCase(); } export function configure(config) { diff --git a/test/html-resource-plugin.spec.js b/test/html-resource-plugin.spec.js index 5276f37..e8873c9 100644 --- a/test/html-resource-plugin.spec.js +++ b/test/html-resource-plugin.spec.js @@ -3,6 +3,7 @@ import {getElementName} from '../src/html-resource-plugin'; describe('html-resource-plugin', () => { it('computes element name', () => { expect(getElementName('foo.html')).toBe('foo'); + expect(getElementName('FOO.HTML')).toBe('foo'); expect(getElementName('/foo.html')).toBe('foo'); expect(getElementName('bar/foo.html')).toBe('foo'); expect(getElementName('foo.html?bar')).toBe('foo');