File tree 2 files changed +22
-3
lines changed 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,10 @@ async function listDataResources(dataPackageUri: Uri): Promise<void> {
40
40
const dataResources : Array < QuickPickItem > = [ ] ;
41
41
dataPackage . resources . forEach ( ( resource : any ) => {
42
42
if ( resource . tabular ) { // supportedDataFormats.includes(resource.descriptor.format)) {
43
- const dataRepositoryUrl : string = '' ; // `https://github.com/${dataPackage.user}/${dataPackage.repo}`;
44
43
dataResources . push ( {
45
44
label : `$(table) ${ resource . name } ` ,
46
45
description : dataPackage . title ,
47
- detail : resource . source
46
+ detail : fileUtils . convertToGitHubRepositoryUrl ( resource . source )
48
47
} ) ;
49
48
}
50
49
} ) ;
@@ -56,7 +55,7 @@ async function listDataResources(dataPackageUri: Uri): Promise<void> {
56
55
let dataResourceUrl : string | undefined = selectedDataResource . detail ;
57
56
if ( dataResourceUrl ) {
58
57
// create tabular data resource Uri and display a table view
59
- const dataResourceUri : Uri = Uri . parse ( dataResourceUrl ) ;
58
+ const dataResourceUri : Uri = Uri . parse ( fileUtils . convertToGitHubContentUrl ( dataResourceUrl ) ) ;
60
59
commands . executeCommand ( ViewCommands . viewTable , dataResourceUri ) ;
61
60
}
62
61
}
Original file line number Diff line number Diff line change @@ -33,6 +33,26 @@ export function convertToGitHubContentUrl(dataFileUrl: string): string {
33
33
return gitHubContentUrl ;
34
34
}
35
35
36
+ /**
37
+ * Converts github content url to user friendly github repository url for display
38
+ * and linking to external public data sources hosted on github.
39
+ *
40
+ * @param dataFileUrl Github content data file url from a github repository.
41
+ * @returns User friendly github data file url for display, linking and copy/paste in a browser.
42
+ */
43
+ export function convertToGitHubRepositoryUrl ( dataFileUrl : string ) : string {
44
+ let gitHubContentUrl : string = dataFileUrl ;
45
+ if ( dataFileUrl . startsWith ( 'https://raw.githubusercontent.com/' ) ) {
46
+ // rewrite github content url to use github repository url for display
47
+ gitHubContentUrl = dataFileUrl . replace ( 'https://raw.githubusercontent.com/' , 'https://github.com/' ) ;
48
+
49
+ // add blob part
50
+ gitHubContentUrl = gitHubContentUrl . replace ( '/main/' , '/blob/main/' ) ;
51
+ gitHubContentUrl = gitHubContentUrl . replace ( '/master/' , '/blob/master/' ) ;
52
+ }
53
+ return gitHubContentUrl ;
54
+ }
55
+
36
56
/**
37
57
* Gets file name path token from a document Uri.
38
58
*
You can’t perform that action at this time.
0 commit comments