-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preferences: fix regex incompatible with Firefox
Firefox doesn't handle lookahead/lookbehind patterns in regexes, leading to Theia applications not starting when ran inside Firefox. This commit replaces the problematic regex with a method that produces the same result. Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
- Loading branch information
1 parent
ac8efa2
commit fa7fb7d
Showing
2 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/preferences/src/browser/util/preference-tree-generator.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom'; | ||
const disableJSDOM = enableJSDOM(); | ||
|
||
import { expect } from 'chai'; | ||
import { Container } from 'inversify'; | ||
import { PreferenceTreeGenerator } from './preference-tree-generator'; | ||
import { PreferenceSchemaProvider } from '@theia/core/lib/browser'; | ||
import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations'; | ||
|
||
disableJSDOM(); | ||
|
||
describe('preference-tree-generator', () => { | ||
|
||
let preferenceTreeGenerator: PreferenceTreeGenerator; | ||
|
||
beforeEach(() => { | ||
const container = new Container(); | ||
container.bind<any>(PreferenceSchemaProvider).toConstantValue(undefined); | ||
container.bind<any>(PreferenceConfigurations).toConstantValue(undefined); | ||
preferenceTreeGenerator = container.resolve(PreferenceTreeGenerator); | ||
}); | ||
|
||
it('PreferenceTreeGenerator.split', () => { | ||
// We want to ensure that our `split` function emulates the following regex properly: | ||
const splitter = /[\W_]|(?<=[^A-Z])(?=[A-Z])/; | ||
const testString = 'aaaBbb.Ccc d E fff GGGgg_iiiJ0a'; | ||
expect(preferenceTreeGenerator['split'](testString)).deep.eq(testString.split(splitter)); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters