Skip to content

Commit 487d8cb

Browse files
authored
Merge pull request #61 from jrswab/f-search-with-numbers
Allow Numbers in Search
2 parents 120d8d9 + cd234ba commit 487d8cb

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

trie/trie.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ func removeNonAlpha(fileName string) string {
159159
s = strings.ReplaceAll(s, ".org", "")
160160

161161
// Step 3: Keep only letter characters
162-
letters := []rune{}
162+
uniRune := []rune{}
163163
for _, r := range s {
164-
if unicode.IsLetter(r) {
165-
letters = append(letters, r)
164+
if unicode.IsLetter(r) || unicode.IsDigit(r) {
165+
uniRune = append(uniRune, r)
166166
}
167167
}
168-
s = string(letters)
168+
s = string(uniRune)
169169

170170
// NFC = Normalization Form Canonical Composition
171171
// This ensures that characters like "é" are treated consistently

trie/trie_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestInit(t *testing.T) {
2626
"basic files without aliases": {
2727
files: map[string]string{
2828
"test-one.md": "# Test 1\nSome content",
29-
"test two.md": "# Test 2\nMore content",
29+
"test 2.md": "# Test 2\nMore content",
3030
},
3131
wantErr: false,
3232
checkFn: func(t *testing.T, tr *trie.Trie) {
@@ -35,9 +35,9 @@ func TestInit(t *testing.T) {
3535
t.Errorf("Expected to find test-one.md in trie, got %v", results)
3636
}
3737

38-
results = tr.Search("test2")
39-
if !slices.Contains(results, "test-one.md") {
40-
t.Errorf("Expected to find \"test two.md\" in trie, got %v", results)
38+
results = tr.Search("test 2")
39+
if !slices.Contains(results, "test 2.md") {
40+
t.Errorf("Expected to find \"test 2.md\" in trie, got %v", results)
4141
}
4242
},
4343
},

0 commit comments

Comments
 (0)