Skip to content

Commit

Permalink
Improves the method of revealing the baseResourcePath.
Browse files Browse the repository at this point in the history
  • Loading branch information
luxmargos committed Feb 9, 2024
1 parent 3f53fac commit d5fc6a0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { clearCaches } from "./img_cache";
import { cloneDeep } from "lodash-es";
import { ImgkPluginSettings } from "./settings/setting_types";
import fileUrl from "file-url";
import { logLevelMobilePatcher } from "./utils/log_utils";

export default class ImgMagicianPlugin extends MainPlugin {
settings: ImgkPluginSettings;
Expand Down Expand Up @@ -445,12 +446,12 @@ export default class ImgMagicianPlugin extends MainPlugin {
}

if(this.baseResourcePath){
if(!this.baseResourcePath.startsWith("/")){
try{
const url = new URL(fileUrl(this.baseResourcePath));
this.baseResourcePath = url.pathname;
}catch(e){}
}
try{
const fileUrlString = fileUrl(this.baseResourcePath);
const url = new URL(fileUrlString);
this.baseResourcePath = url.pathname;
}catch(e){}

if(this.baseResourcePath){
this.baseResourcePathIdx = this.baseResourcePath?.length ?? -1;
}
Expand Down

0 comments on commit d5fc6a0

Please sign in to comment.