Skip to content

Commit

Permalink
Handle legacy urls
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kus committed Jun 10, 2020
1 parent d9e2218 commit cad4d15
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "better-call-dev",
"version": "2.5.1",
"version": "2.5.2",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
5 changes: 3 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import store from '@/store'
import router from '@/router'
import VueAnalytics from 'vue-analytics'

import { shortcut, formatDatetime, formatDate, plural } from "@/utils/tz.js";
import { shortcut, formatDatetime, formatDate, plural, urlExtractBase58 } from "@/utils/tz.js";
import { getJwt, logout, getBool } from "@/utils/auth.js";
import { BetterCallApi, UnauthorizedError } from "@/api/bcd.js"
import { NodeRPC } from "@/api/rpc.js"
Expand Down Expand Up @@ -90,7 +90,8 @@ getRuntimeConfig().then(function (config) {
{
path: '*',
redirect: to => {
return { name: 'search', query: { text: to.path.slice(1) } }
const text = urlExtractBase58(to.path) || to.path.split('/').join(' ');
return { name: 'search', query: { text } };
}
}
]);
Expand Down
7 changes: 7 additions & 0 deletions src/utils/tz.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ export function formatDate(timestamp) {

export function plural(count, noun, suffix = 's') {
return `${count} ${noun}${count !== 1 ? suffix : ''}`;
}

export function urlExtractBase58(url) {
const matches = url.match(/\b(tz|KT|o|expr)[1-9A-HJ-NP-Za-km-z]{34,}\b/);
if (matches && matches.length > 0) {
return matches[0];
}
}
2 changes: 1 addition & 1 deletion src/views/contract/CodeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</v-btn>
<v-btn small text @click="downloadFile" class="text--secondary ml-2">
<v-icon class="mr-1 text--secondary" small>mdi-download-outline</v-icon>
<span>Download as .tz</span>
<span>Download</span>
</v-btn>
<v-btn small text @click="openTryMichelson" class="text--secondary ml-2">
<v-icon class="mr-1 text--secondary" small>mdi-play-circle-outline</v-icon>
Expand Down
20 changes: 10 additions & 10 deletions src/views/contract/StorageTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
<v-icon class="mr-1" small>mdi-code-json</v-icon>
<span>Raw JSON</span>
</v-btn>
<v-btn v-if="raw" @click="getStorage()" class="ml-2 text--secondary" small text>
<v-icon class="mr-1" small>mdi-file-tree</v-icon>
<span>Switch to Tree View</span>
</v-btn>
<v-btn v-else @click="getStorageRaw()" class="ml-2 text--secondary" small text>
<v-icon class="mr-1" small>mdi-code-parentheses</v-icon>
<span>Switch to Micheline</span>
</v-btn>
<v-tooltip v-if="!raw" top>
<template v-slot:activator="{ on }">
<v-btn
Expand All @@ -32,7 +24,7 @@
:disabled="downloading"
>
<v-icon class="mr-1" small>mdi-download-outline</v-icon>
<span>Download as .json</span>
<span>Full dump</span>
</v-btn>
</template>
Raw snapshot with all big map data
Expand All @@ -48,7 +40,15 @@
text
>
<v-icon class="mr-1" small>mdi-content-copy</v-icon>
<span class="text--secondary">Copy as string</span>
<span class="text--secondary">Copy</span>
</v-btn>
<v-btn v-if="raw" @click="getStorage()" class="ml-2 text--secondary" small text>
<v-icon class="mr-1" small>mdi-file-tree</v-icon>
<span>Switch to Tree View</span>
</v-btn>
<v-btn v-else @click="getStorageRaw()" class="ml-2 text--secondary" small text>
<v-icon class="mr-1" small>mdi-code-parentheses</v-icon>
<span>Switch to Micheline</span>
</v-btn>
</v-card-title>
<v-card-text class="pa-0">
Expand Down

0 comments on commit cad4d15

Please sign in to comment.