diff --git a/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.html b/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.html
index bf39f394..2fdc4054 100644
--- a/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.html
+++ b/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.html
@@ -16,8 +16,8 @@
class="sky-test-div-container"
[skyHighlight]="searchTerm"
>
- Here is some test text.
+ {{innerText1}}
- Here is (additional) {{"{text}"}} that was previously hidden in src\app.
+ {{innerText2}}
diff --git a/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.ts b/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.ts
index e102ef3d..1317451d 100644
--- a/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.ts
+++ b/src/app/public/modules/text-highlight/fixtures/text-highlight.component.fixture.ts
@@ -8,4 +8,6 @@ import { Component } from '@angular/core';
export class SkyTextHighlightTestComponent {
public searchTerm: string;
public showAdditionalContent: boolean = false;
+ public innerText1: string = 'Here is some test text.';
+ public innerText2: string = 'Here is additional text that was previously hidden in src\\app.';
}
diff --git a/src/app/public/modules/text-highlight/text-highlight.directive.spec.ts b/src/app/public/modules/text-highlight/text-highlight.directive.spec.ts
index 229be420..1d7180d0 100644
--- a/src/app/public/modules/text-highlight/text-highlight.directive.spec.ts
+++ b/src/app/public/modules/text-highlight/text-highlight.directive.spec.ts
@@ -140,33 +140,19 @@ describe('Text Highlight', () => {
const text = 'Here is some test text.';
// tslint:disable-next-line:max-line-length
- const additional = 'Here is (additional) {text} that was previously hidden in src\\app.';
+ const additional = `Here is additional text that was previously hidden in src\\app.`;
const expectedHtml = getHtmlOutputAdditionalText(text, additional);
expect(containerEl.innerHTML.trim()).toBe(expectedHtml);
});
it('should support illegal characters in the search term', () => {
- component.showAdditionalContent = true;
+ component.innerText1 = 'foo-\/^$*+?.()|{}[]bar';
fixture.detectChanges();
- // Check for \ and .
- updateInputText(fixture, 'src\\app.');
- const text = 'Here is some test text.';
- let additional = 'Here is (additional) {text} that was previously hidden in src\\app.';
- let expectedHtml = getHtmlOutputAdditionalText(text, additional);
- expect(containerEl.innerHTML.trim()).toBe(expectedHtml);
-
- // Check for ()
- updateInputText(fixture, '(additional)');
- additional = 'Here is (additional) {text} that was previously hidden in src\\app.';
- expectedHtml = getHtmlOutputAdditionalText(text, additional);
- expect(containerEl.innerHTML.trim()).toBe(expectedHtml);
-
- // Check for {}
- updateInputText(fixture, '{text}');
- additional = 'Here is (additional) {text} that was previously hidden in src\\app.';
- expectedHtml = getHtmlOutputAdditionalText(text, additional);
+ updateInputText(fixture, '-\/^$*+?.()|{}[]');
+ const expectedHtml =
+ getHtmlOutput('foo-\/^$*+?.()|{}[]bar');
expect(containerEl.innerHTML.trim()).toBe(expectedHtml);
});
@@ -215,7 +201,7 @@ describe('Text Highlight', () => {
const text = 'Here is some test text.';
// tslint:disable-next-line:max-line-length
- const additional = 'Here is (additional) {text} that was previously hidden in src\\app.';
+ const additional = 'Here is additional text that was previously hidden in src\\app.';
const expectedHtmlChanged = getHtmlOutputAdditionalText(text, additional);
expect(containerElUpdated.innerHTML.trim()).toBe(expectedHtmlChanged);
@@ -249,7 +235,7 @@ describe('Text Highlight', () => {
const text = 'Here is some test text.';
// tslint:disable-next-line:max-line-length
- const additional = 'Here is (additional) {text} that was previously hidden in src\\app.';
+ const additional = 'Here is additional text that was previously hidden in src\\app.';
const expectedHtmlChanged = getHtmlOutputAdditionalText(text, additional);
expect(containerElUpdated.innerHTML.trim()).toBe(expectedHtmlChanged);
diff --git a/src/app/public/modules/text-highlight/text-highlight.directive.ts b/src/app/public/modules/text-highlight/text-highlight.directive.ts
index 1558bc78..2d7b76fc 100644
--- a/src/app/public/modules/text-highlight/text-highlight.directive.ts
+++ b/src/app/public/modules/text-highlight/text-highlight.directive.ts
@@ -149,12 +149,6 @@ export class SkyTextHighlightDirective
}
private static cleanRegex(regex: string) {
- return regex
- .replace(/\\/g, '\\\\')
- .replace(/\(/g, '\\(')
- .replace(/\)/g, '\\)')
- .replace(/\{/g, '\\{')
- .replace(/\}/g, '\\}')
- .replace(/\./g, '\\.');
+ return regex.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
}