Skip to content

Commit

Permalink
Merge pull request bpking1#463 from chen3861229/main
Browse files Browse the repository at this point in the history
fix(emby2Alist&plex2Alist): 修复 getClientSelfAlistLink 编码
  • Loading branch information
chen3861229 authored Dec 27, 2024
2 parents bea610e + 5593f40 commit ee93930
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
19 changes: 17 additions & 2 deletions emby2Alist/nginx/conf.d/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,17 @@ function simpleRuleFilter(r, ruleArr3D, filePath, firstSourceStr, mark) {
}
}

/**
* getClientSelfAlistLink
* @param {Object} r nginx objects, HTTP Request
* @param {String} filePath mediaFilePath or alist raw_url, like: http://xxx
* @param {String} alistFilePath null or mapped mediaItemPath, like: /file.mp4 or any string, depend on mediaPathMapping rule
* @returns alist dUrl
*/
function getClientSelfAlistLink(r, filePath, alistFilePath) {
if (!filePath) {
return r.warn(`args[1] filePath is required`);
}
let rule = simpleRuleFilter(r, config.clientSelfAlistRule, filePath, SOURCE_STR_ENUM.alistRes, "clientSelfAlistRule");
if (rule && rule.length > 0) {
if (!Number.isInteger(rule[0])) {
Expand All @@ -499,8 +509,13 @@ function getClientSelfAlistLink(r, filePath, alistFilePath) {
rule = rule.slice(2);
}
const alistPublicAddr = rule.length === 3 ? rule[2] : config.alistPublicAddr;
// @param {String} filePath mediaFilePath or alistRes link
return `${alistPublicAddr}/d${encodeURIComponent(alistFilePath || filePath)}`;
if (alistFilePath && alistFilePath.startsWith("/")) {
alistFilePath = alistFilePath.substring(1);
}
if (filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
return `${alistPublicAddr}/d/${encodeURIComponent(alistFilePath || filePath)}`;
}
}

Expand Down
19 changes: 17 additions & 2 deletions plex2Alist/nginx/conf.d/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,17 @@ function simpleRuleFilter(r, ruleArr3D, filePath, firstSourceStr, mark) {
}
}

/**
* getClientSelfAlistLink
* @param {Object} r nginx objects, HTTP Request
* @param {String} filePath mediaFilePath or alist raw_url, like: http://xxx
* @param {String} alistFilePath null or mapped mediaItemPath, like: /file.mp4 or any string, depend on mediaPathMapping rule
* @returns alist dUrl
*/
function getClientSelfAlistLink(r, filePath, alistFilePath) {
if (!filePath) {
return r.warn(`args[1] filePath is required`);
}
let rule = simpleRuleFilter(r, config.clientSelfAlistRule, filePath, SOURCE_STR_ENUM.alistRes, "clientSelfAlistRule");
if (rule && rule.length > 0) {
if (!Number.isInteger(rule[0])) {
Expand All @@ -481,8 +491,13 @@ function getClientSelfAlistLink(r, filePath, alistFilePath) {
rule = rule.slice(2);
}
const alistPublicAddr = rule.length === 3 ? rule[2] : config.alistPublicAddr;
// @param {String} filePath mediaFilePath or alistRes link
return `${alistPublicAddr}/d${encodeURIComponent(alistFilePath || filePath)}`;
if (alistFilePath && alistFilePath.startsWith("/")) {
alistFilePath = alistFilePath.substring(1);
}
if (filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
return `${alistPublicAddr}/d/${encodeURIComponent(alistFilePath || filePath)}`;
}
}

Expand Down

0 comments on commit ee93930

Please sign in to comment.