Skip to content

Commit

Permalink
fix the warning of regex
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hub committed Jun 1, 2023
1 parent e9b3d89 commit 9f98ff2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/VerseSuggesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { BibleVerseReferenceLinkPosition } from './data/BibleVerseReferenceLinkP
import { BibleVerseNumberFormat } from './data/BibleVerseNumberFormat'
import { BibleVerseFormat } from './data/BibleVerseFormat'

const BOOK_REGEX = /[123]*[ ]*[a-zA-Z]{3,}/
const CHAPTER_REGEX = /[123]*[ ]*[a-zA-Z]{3,}[ ]*[0-9]*/


export class VerseSuggesting implements IVerseSuggesting {
public text: string
public verses: string
Expand Down Expand Up @@ -63,19 +67,19 @@ export class VerseSuggesting implements IVerseSuggesting {
// and regex to clean book and chapters that will match
// across multiple different search queires
if (this.settings?.bookBacklinking){
head += ` [[${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}/)![0].replace(/\s+/g, '').toLowerCase()}]]`
head += ` [[${this.bibleProvider.BibleReferenceHead.match(BOOK_REGEX)![0].replace(/\s+/g, '').toLowerCase()}]]`
}
if (this.settings?.chapterBacklinking){
head += ` [[${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}[ ]*[0-9]*/)![0].replace(/\s+/g, '').toLowerCase()}]]`
head += ` [[${this.bibleProvider.BibleReferenceHead.match(CHAPTER_REGEX)![0].replace(/\s+/g, '').toLowerCase()}]]`
}
if (
this.settings?.bibleTagging ||
this.settings?.bookTagging ||
this.settings?.chapterTagging) {
bottom += ' %%'
bottom += (this.settings?.bibleTagging) ? ' #bible' : ''
bottom += (this.settings?.bookTagging) ? ` #${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}/)![0].replace(/\s+/g, '').toLowerCase()}` : ''
bottom += (this.settings?.chapterTagging) ? ` #${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}[ ]*[0-9]*/)![0].replace(/\s+/g, '').toLowerCase()}` : ''
bottom += (this.settings?.bookTagging) ? ` #${this.bibleProvider.BibleReferenceHead.match(BOOK_REGEX)![0].replace(/\s+/g, '').toLowerCase()}` : ''
bottom += (this.settings?.chapterTagging) ? ` #${this.bibleProvider.BibleReferenceHead.match(CHAPTER_REGEX)![0].replace(/\s+/g, '').toLowerCase()}` : ''
bottom += ' %%'
}

Expand Down

0 comments on commit 9f98ff2

Please sign in to comment.