Skip to content
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

Redirect un-encoded player URLs if possible #866

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion src/views/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</template>

<script lang="ts">
import { computed, defineComponent, onUnmounted, ref, watch } from "vue";
import { computed, defineComponent, onMounted, onUnmounted, ref, watch } from "vue";
import { PlayerProfile } from "@/store/player/types";
import { EGameMode, ERaceEnum, Match, PlayerInTeam, Team } from "@/store/types";
import { Season } from "@/store/ranking/types";
Expand Down Expand Up @@ -240,6 +240,19 @@ export default defineComponent({
clearInterval(_intervalRefreshHandle);
}

onMounted((): void => {
// Since # is a reserver character for the "fragment/hash" part of the URL
// we can try to redirect to the correct URL if the hash is a battle tag,
// (starts with at least 4 digits). It may also be followed by a tab name,
// for example Someone#9999/matches would redirect to Someone%239999/matches
if (window.location.hash.match(/^#\d{4}/)) {
const url = new URL(window.location.href);
url.pathname = `${url.pathname}${url.hash}`;
url.hash = "";
window.location.href = url.toString();
}
});

onUnmounted((): void => {
stopLoadingMatches();
});
Expand Down