Skip to content

fix(UrlContextProvider): Decode URL parameter filePath once read from the window's location (fixes #109). #151

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions docs/src/user-guide/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ The log viewer can open local or remote log files. The viewer currently supports
and [JSONL] log files.

## Opening local log files
To open a local file, click the folder icon ({far}`folder`) in the top-left corner. This will open a file
browser where you can navigate to and select the log file to open.
To open a local file, click the folder icon ({far}`folder`) in the top-left corner. This will open a
file browser where you can navigate to and select the log file to open.

## Opening remote log files
To open a remote file, append `/?filePath=<FILE_URL>` to the current URL, replacing `<FILE_URL>`
with the URL of your log file.
with the URL of your log file. The `<FILE_URL>` can be directly supplied without being URL encoded,
even if it contains any search parameters for authentication purposes for example, because the
viewer expects `filePath` to always be the last search parameter in the viewer's URL. However, if
the `<FILE_URL>` contains a hash parameter, the whole URL should be URL-encoded to avoid ambiguity
of ownership of the hash parameter.

[CLP]: https://github.com/y-scope/clp
[JSONL]: https://jsonlines.org/
3 changes: 2 additions & 1 deletion src/contexts/UrlContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ const getWindowUrlSearchParams = () => {
// This ensures any parameters following `filePath=` are incorporated into the `filePath`.
const [, filePath] = window.location.search.split("filePath=");
if ("undefined" !== typeof filePath && 0 !== filePath.length) {
searchParams[SEARCH_PARAM_NAMES.FILE_PATH] = getAbsoluteUrl(filePath);
const decodedFilePath = decodeURIComponent(filePath);
searchParams[SEARCH_PARAM_NAMES.FILE_PATH] = getAbsoluteUrl(decodedFilePath);
}
}

Expand Down