File tree 4 files changed +13
-5
lines changed
4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @bluecadet/launchpad-content " : patch
3
+ ---
4
+
5
+ Fix json content source media URL scraping
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ class JsonSource extends ContentSource {
54
54
*/
55
55
async _downloadJsons ( ) {
56
56
const result = new ContentResult ( ) ;
57
-
58
57
for ( const [ path , url ] of Object . entries ( this . config . files ) ) {
59
58
this . logger . debug ( `Downloading json ${ chalk . blue ( url ) } ` ) ;
60
59
const response = await got ( url ) ;
@@ -74,7 +73,7 @@ class JsonSource extends ContentSource {
74
73
for ( const dataFile of result . dataFiles ) {
75
74
this . logger . debug ( `Scraping for media files in ${ chalk . blue ( dataFile . localPath ) } ...` ) ;
76
75
const mediaUrls = JsonUtils . getUrls ( dataFile . content , undefined , this . config . mediaPattern ) ;
77
- this . logger . debug ( `Found ${ chalk . blue ( mediaUrls . size ) } media files in ${ chalk . blue ( dataFile . localPath ) } ` ) ;
76
+ this . logger . debug ( `Found ${ chalk . blue ( mediaUrls . size . toString ( ) ) } media files in ${ chalk . blue ( dataFile . localPath ) } ` ) ;
78
77
result . addMediaDownloads ( [ ...mediaUrls ] . map ( url => new MediaDownload ( { url } ) ) ) ;
79
78
}
80
79
return result ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class JsonUtils {
22
22
}
23
23
24
24
const possibleUrls = getUrls ( JSON . stringify ( json ) , config ) ;
25
+
25
26
for ( const url of possibleUrls ) {
26
27
if ( include && ( include instanceof RegExp ) && ! url . match ( include ) ) {
27
28
continue ; // url doesn't match include
@@ -35,15 +36,17 @@ class JsonUtils {
35
36
}
36
37
37
38
/**
38
- * @param {any } [userSettings]
39
+ * @param {import('get-urls').Options } [userSettings]
40
+ * @returns {import('get-urls').Options }
39
41
*/
40
42
static getUrlOptions ( userSettings ) {
41
43
return {
42
44
...{
43
45
stripAuthentication : false ,
44
46
stripWWW : false ,
45
47
removeTrailingSlash : false ,
46
- sortQueryParameters : false
48
+ sortQueryParameters : false ,
49
+ requireSchemeOrWww : true
47
50
} ,
48
51
...userSettings
49
52
} ;
Original file line number Diff line number Diff line change 45
45
"contentful" : " ^9.0.0" ,
46
46
"filenamify" : " ^5.1.1" ,
47
47
"fs-extra" : " ^10.0.0" ,
48
- "get-urls" : " ^10.0 .0" ,
48
+ "get-urls" : " ^12.1 .0" ,
49
49
"got" : " ^12.3.0" ,
50
50
"jsonpath" : " ^1.1.1" ,
51
51
"markdown-it" : " ^12.2.0" ,
60
60
"devDependencies" : {
61
61
"@types/cli-progress" : " ^3.11.0" ,
62
62
"@types/jsonpath" : " ^0.2.0" ,
63
+ "@types/markdown-it" : " ^12.2.0" ,
63
64
"@types/progress-stream" : " ^2.0.2" ,
64
65
"@types/qs" : " ^6.9.7" ,
65
66
"@types/rimraf" : " ^4.0.5" ,
You can’t perform that action at this time.
0 commit comments