File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed
Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 22 "name" : " patch-roulette-web-extension" ,
33 "displayName" : " diffs.dev" ,
44 "description" : " Streamlines opening diffs in the diffs.dev Diff Viewer." ,
5- "version" : " 0.0.8 " ,
5+ "version" : " 0.0.9 " ,
66 "private" : true ,
77 "type" : " module" ,
88 "scripts" : {
Original file line number Diff line number Diff line change @@ -9,13 +9,21 @@ export async function getViewerUrl() {
99 return url ;
1010}
1111
12- export async function openInPatchRoulette ( url : string ) {
12+ export async function openInDiffViewer ( url : string ) {
1313 const viewerUrl = await getViewerUrl ( ) ;
1414 try {
1515 if ( url . startsWith ( viewerUrl ) ) {
1616 return ;
1717 }
18- const newUrl = viewerUrl + "?github_url=" + encodeURIComponent ( url ) ;
18+
19+ const parsedUrl = new URL ( url ) ;
20+ let newUrl : string ;
21+ if ( parsedUrl . hostname === "github.com" ) {
22+ newUrl = viewerUrl + "?github_url=" + encodeURIComponent ( url ) ;
23+ } else {
24+ newUrl = viewerUrl + "?patch_url=" + encodeURIComponent ( url ) ;
25+ }
26+
1927 const activeTab = await getActiveTab ( ) ;
2028 await chrome . tabs . create ( {
2129 url : newUrl ,
Original file line number Diff line number Diff line change 1- import { getActiveTab , openInPatchRoulette } from "./common.ts" ;
1+ import { getActiveTab , openInDiffViewer } from "./common.ts" ;
22
33const button = document . getElementById ( "open-button" ) as HTMLButtonElement ;
44const settingsButton = document . getElementById ( "settings-button" ) as HTMLButtonElement ;
@@ -10,7 +10,7 @@ if (!button || !settingsButton) {
1010button . addEventListener ( "click" , async ( ) => {
1111 const activeTab = await getActiveTab ( ) ;
1212 if ( activeTab && activeTab . url ) {
13- await openInPatchRoulette ( activeTab . url ) ;
13+ await openInDiffViewer ( activeTab . url ) ;
1414 window . close ( ) ;
1515 }
1616} ) ;
Original file line number Diff line number Diff line change 1- import { openInPatchRoulette } from "./common.ts" ;
1+ import { openInDiffViewer } from "./common.ts" ;
22import browser from "webextension-polyfill" ;
33
44function createContextMenu ( ) {
@@ -18,6 +18,6 @@ browser.contextMenus.onClicked.addListener(async (info, tab) => {
1818 url = tab . url ;
1919 }
2020 if ( url ) {
21- await openInPatchRoulette ( url ) ;
21+ await openInDiffViewer ( url ) ;
2222 }
2323} ) ;
You can’t perform that action at this time.
0 commit comments