hebcal/hebcal-js

findSedra should work better

Closed this issue · 4 comments

var year = new Hebcal(5775); // define the year

year.findSedra('Miketz') // good
year.findSedra('miketz') // not found
year.findSedra('מקץ') // not found
year.findSedra('מקצ','h') // not found
year.findParsha('Shemos','a') // good
year.findParsha('Shemos') // nope

Expected behavior: Find the parsha regardless of spelling.

Can you please detail the fixes, since your commit says "partially fixes?"

@MosheBerman Now it searches all spellings, but is still case sensitive.

year.findSedra('Miketz') // good
year.findSedra('miketz') // not found
year.findSedra('מקץ') // found -- new!
year.findSedra('מקצ','h') // not found
year.findParsha('Shemos','a') // good
year.findParsha('Shemos') // found -- new!

Ah, cool! What do the 'h', and 'a' arguments do?

I'm thinking that you can do some basic operations to solve this. For the english strings, storing them as all lowercase, then lowercasing any english search string would solve the problem. And replacing the 5 end characters for your מקץ/מקצ case should also be fairly simple. The principle is the same:

Pick a canonical storage format and convert any incoming queries to that format. For display, it might become necessary to format again (for example, back to uppercase.)

I'm not sure if I'm going to break things by changing your arrays. Does anything else depend on that code being uppercase or spelled a specific way?