Resolving File Search Issues: Handling Special Characters and Ensuring Correct URL Encoding #1044
azizul939
started this conversation in
Show and tell
Replies: 1 comment
-
@azizul939 thanks for sharing, can you create a PR. it will be useful for others. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I noticed that clicking the link in the search results for a folder or file with special characters would not display the file even if it exists. To address this issue, I made the following adjustments to the code:
// Search template
function search_template(data) {
var response = "";
$.each(data, function (key, val) {
var encodedPath = encodeURIComponent(val.path);
var encodedName = encodeURIComponent(val.name);
var url =
?p=${encodedPath}&view=${encodedName}
;response +=
<li><a href="${url}">${val.path}/${val.name}</a></li>
;});
return response;
}
In this code, I resolved the issue by using the encodeURIComponent() function separately for the val.path and val.name variables. This ensures that special characters are properly encoded before concatenating them in the URL. As a result, the search links now direct to the correct file, even if it contains special characters.
Beta Was this translation helpful? Give feedback.
All reactions