Skip to content

Commit

Permalink
fix: origin path preparing
Browse files Browse the repository at this point in the history
  • Loading branch information
LorexIQ committed Mar 27, 2024
1 parent 870f564 commit 22b5c32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/runtime/composables/useLocalAuthState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useUtils from "../composables/useUtils";
import { computed, watch } from "vue";
import { useCookie, useState, useRuntimeConfig } from "#app";

const { trimWithSymbol } = useUtils();
const { trimEndWithSymbol } = useUtils();

export default function () {
const options = useRuntimeConfig().public.localAuth as ModuleOptions;
Expand Down Expand Up @@ -45,7 +45,7 @@ export default function () {
}, { immediate: true }));

const token = computed(() => sessionMetaInfo.value.token ? `${options.token.type} ${sessionMetaInfo.value.token}`.trim() : null);
const origin = trimWithSymbol(options.origin, '/');
const origin = trimEndWithSymbol(options.origin, '/');

function parseValueWithPath<T = string>(data: UseLocalAuthResponse, path: string): T | undefined {
return path
Expand Down
5 changes: 5 additions & 0 deletions src/runtime/composables/useUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class Utils {

return str.substring(startTrim ? symbol.length : 0);
}
trimEndWithSymbol(str: string, symbol: string): string {
const endTrim = str.endsWith(symbol);

return str.substring(0, endTrim ? str.length - symbol.length : str.length);
}
}

const utils = new Utils();
Expand Down

0 comments on commit 22b5c32

Please sign in to comment.