Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 fixes an incorrect check for a string instead of regexp #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/viewer/SatelliteGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ class SatelliteGroup {
* @throws {Error} If nameRegex is not a string.
*/
private searchNameRegex () {
if (typeof this.data !== 'string') {
throw new Error('nameRegex must be a string');
if (typeof this.data === 'string') {
throw new Error('nameRegex must be a RegExp');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there may be a small issue, since we are now loading the groups from the config.json, since here the regular expressions are strings and we haven't done any conversions to a RegExp. For this reason we should probably support both strings and RegExp, converting any string to RegExp:

    let regex: RexExp; 
    if (typeof this.data === 'string') {
      regex = new RegExp(this.data);
    } else if (this.data instanceof RegExp) {
      regex = this.data;
    } else {
      throw new Error('nameRegex must be a RegExp or a regex in string form');
    }

}
const regex = new RegExp(this.data);

// These are set as regular expressions in the config file.
const regex = this.data as RegExp;
const satIdList = this.satelliteStore.searchNameRegex(regex);
for (const satId of satIdList) {
this.sats.push({
Expand Down