From bed1a6c7ec7415fc48a09c20a860e05c16e96a88 Mon Sep 17 00:00:00 2001 From: netcon Date: Wed, 18 May 2022 22:07:52 +0800 Subject: [PATCH] fix: can not change github file ecoding (#404) --- .../github1s/src/adapters/sourcegraph/data-source.ts | 8 ++++---- resources/initialize.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/github1s/src/adapters/sourcegraph/data-source.ts b/extensions/github1s/src/adapters/sourcegraph/data-source.ts index ab307354c..1ac6b6d9b 100644 --- a/extensions/github1s/src/adapters/sourcegraph/data-source.ts +++ b/extensions/github1s/src/adapters/sourcegraph/data-source.ts @@ -107,14 +107,14 @@ export class SourcegraphDataSource extends DataSource { }); async provideFile(repo: string, ref: string, path: string): Promise { - const { content, binary } = await readFile(this.buildRepository(repo), ref, path); - // sourcegraph api break binary files, so we use github api here - // TODO: fix fetch binary files in gitlab/bitbucket - if (binary && this.platform === 'github') { + // sourcegraph api break binary files and text coding, so we use github api here + if (this.platform === 'github') { return fetch(`https://raw.githubusercontent.com/${repo}/${ref}/${path}`) .then((response) => response.arrayBuffer()) .then((buffer) => ({ content: new Uint8Array(buffer) })); } + // TODO: support binary files for other platforms + const { content } = await readFile(this.buildRepository(repo), ref, path); return { content: this.textEncodder.encode(content) }; } diff --git a/resources/initialize.js b/resources/initialize.js index 0adb91e16..81361d9b5 100644 --- a/resources/initialize.js +++ b/resources/initialize.js @@ -42,7 +42,7 @@ } else if (hostname.match(/\.?bitbucket1s\.org$/)) { scheme = 'bitbucket1s'; platformName = 'Bitbucket'; - platformOrigin = 'https://bitbucket1s.com'; + platformOrigin = 'https://bitbucket.org'; logoIcon = staticAssetsPrefix + '/config/bitbucket.svg'; repository = pathParts >= 2 ? pathParts.slice(0, 2).join('/') : 'atlassian/clover'; } @@ -218,7 +218,7 @@ icon: logoIcon, title: 'Open on ' + platformName, onClick() { - const pathname = window.location.pathname > 1 ? window.location.pathname : '/' + repository; + const pathname = window.location.pathname.length > 1 ? window.location.pathname : '/' + repository; const targetPath = pathname + window.location.search + window.location.hash; window.open(platformOrigin + targetPath, '_blank'); },