Skip to content

Commit

Permalink
Use shared GkDotDevUrl constant instead of defining it in every host …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
jdgarcia committed Apr 25, 2024
1 parent 4b65ac1 commit 5257487
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/hosts/azureDevops.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { InjectionProvider, LinkTarget } from '../provider';

declare const MODE: 'production' | 'development' | 'none';
import { GKDotDevUrl } from '../shared';

interface ReplaceSelector {
selector: string;
Expand Down Expand Up @@ -181,7 +180,7 @@ export function injectionScope(url: string) {

private transformUrl(action: 'open' | 'compare', pathname: string, search: URLSearchParams): string {
const redirectUrl = new URL(this.getRedirectUrl('vscode', action, pathname, search));
const deepLinkUrl = MODE === 'production' ? 'https://gitkraken.dev/link' : 'https://dev.gitkraken.dev/link';
const deepLinkUrl = `${GKDotDevUrl}/link`;
const deepLink = new URL(`${deepLinkUrl}/${encodeURIComponent(btoa(redirectUrl.toString()))}`);
deepLink.searchParams.set('referrer', 'extension');
if (redirectUrl.searchParams.get('pr')) {
Expand Down
5 changes: 2 additions & 3 deletions src/hosts/bitbucket.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { InjectionProvider, LinkTarget } from '../provider';

declare const MODE: 'production' | 'development' | 'none';
import { GKDotDevUrl } from '../shared';

interface ReplaceSelector {
selector: string;
Expand Down Expand Up @@ -185,7 +184,7 @@ export function injectionScope(url: string) {

private transformUrl(action: 'open' | 'compare', pathname: string): string {
const redirectUrl = new URL(this.getRedirectUrl('vscode', action, pathname));
const deepLinkUrl = MODE === 'production' ? 'https://gitkraken.dev/link' : 'https://dev.gitkraken.dev/link';
const deepLinkUrl = `${GKDotDevUrl}/link`;
const deepLink = new URL(`${deepLinkUrl}/${encodeURIComponent(btoa(redirectUrl.toString()))}`);
deepLink.searchParams.set('referrer', 'extension');
if (redirectUrl.searchParams.get('pr')) {
Expand Down
5 changes: 2 additions & 3 deletions src/hosts/github.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { InjectionProvider, LinkTarget } from '../provider';

declare const MODE: 'production' | 'development' | 'none';
import { GKDotDevUrl } from '../shared';

export function injectionScope(url: string) {
class GitHubInjectionProvider implements InjectionProvider {
Expand Down Expand Up @@ -253,7 +252,7 @@ export function injectionScope(url: string) {
private transformUrl(action: 'open' | 'compare'): string {
const redirectUrl = new URL(this.getRedirectUrl('vscode', action));
console.debug('redirectUrl', redirectUrl);
const deepLinkUrl = MODE === 'production' ? 'https://gitkraken.dev/link' : 'https://dev.gitkraken.dev/link';
const deepLinkUrl = `${GKDotDevUrl}/link`;
const deepLink = new URL(`${deepLinkUrl}/${encodeURIComponent(btoa(redirectUrl.toString()))}`);
deepLink.searchParams.set('referrer', 'extension');
if (redirectUrl.searchParams.get('pr')) {
Expand Down
5 changes: 2 additions & 3 deletions src/hosts/gitlab.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { InjectionProvider, LinkTarget } from '../provider';

declare const MODE: 'production' | 'development' | 'none';
import { GKDotDevUrl } from '../shared';

export function injectionScope(url: string) {
class GitLabInjectionProvider implements InjectionProvider {
Expand Down Expand Up @@ -253,7 +252,7 @@ export function injectionScope(url: string) {
private transformUrl(action: 'open' | 'compare'): string {
const redirectUrl = new URL(this.getRedirectUrl('vscode', action));
console.debug('redirectUrl', redirectUrl);
const deepLinkUrl = MODE === 'production' ? 'https://gitkraken.dev/link' : 'https://dev.gitkraken.dev/link';
const deepLinkUrl = `${GKDotDevUrl}/link`;
const deepLink = new URL(`${deepLinkUrl}/${encodeURIComponent(btoa(redirectUrl.toString()))}`);
deepLink.searchParams.set('referrer', 'extension');
if (redirectUrl.searchParams.get('pr')) {
Expand Down

0 comments on commit 5257487

Please sign in to comment.