mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
fix(link): search from URL not working (closes #1335)
This commit is contained in:
parent
1ba6104e36
commit
79cc1cbf17
9
src/public/app/services/link.spec.ts
Normal file
9
src/public/app/services/link.spec.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseNavigationStateFromUrl } from "./link.js";
|
||||
|
||||
describe("Link", () => {
|
||||
it("parses plain searchString", () => {
|
||||
const output = parseNavigationStateFromUrl("http://localhost:8080/#?searchString=hello");
|
||||
expect(output).toMatchObject({ searchString: "hello" });
|
||||
});
|
||||
});
|
@ -198,7 +198,7 @@ function calculateHash({ notePath, ntxId, hoistedNoteId, viewScope = {} }: NoteC
|
||||
return hash;
|
||||
}
|
||||
|
||||
function parseNavigationStateFromUrl(url: string | undefined) {
|
||||
export function parseNavigationStateFromUrl(url: string | undefined) {
|
||||
if (!url) {
|
||||
return {};
|
||||
}
|
||||
@ -209,11 +209,7 @@ function parseNavigationStateFromUrl(url: string | undefined) {
|
||||
}
|
||||
|
||||
const hash = url.substr(hashIdx + 1); // strip also the initial '#'
|
||||
const [notePath, paramString] = hash.split("?");
|
||||
|
||||
if (!notePath.match(/^[_a-z0-9]{4,}(\/[_a-z0-9]{4,})*$/i)) {
|
||||
return {};
|
||||
}
|
||||
let [notePath, paramString] = hash.split("?");
|
||||
|
||||
const viewScope: ViewScope = {
|
||||
viewMode: "default"
|
||||
@ -242,6 +238,10 @@ function parseNavigationStateFromUrl(url: string | undefined) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!notePath.match(/^[_a-z0-9]{4,}(\/[_a-z0-9]{4,})*$/i)) {
|
||||
return { searchString }
|
||||
}
|
||||
|
||||
return {
|
||||
notePath,
|
||||
noteId: treeService.getNoteIdFromUrl(notePath),
|
||||
|
Loading…
x
Reference in New Issue
Block a user