Skip to content

Commit 854d6cd

Browse files
authored
Merge pull request #52 from korhox/master
fix: Add custom path encoder
2 parents 4b15622 + 28c0a74 commit 854d6cd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

index.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ <h2 class="subtitle" v-html="config.subtitleHTML"></h2>
304304
return /iPad|iPhone|iPod/.test(navigator.platform) ||
305305
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
306306
}
307+
308+
function encodePath(path) {
309+
const replaceChars = { ";": "%3B", "?": "%3F", ":": "%3A", "@": "%40", "&": "%26", "=": "%3D", "+": "%2B", "$": "%24", ",": "%2C", "#": "%23" }
310+
return encodeURI(path).split("").map(char => replaceChars[char] || char).join("");
311+
}
307312
</script>
308313

309314

@@ -443,7 +448,7 @@ <h2 class="subtitle" v-html="config.subtitleHTML"></h2>
443448
methods: {
444449
moment,
445450
urlFromPathPrefix(pathPrefix) {
446-
return `${(this.config.bucketMaskUrl || this.config.bucketUrl).replace(/\/*$/,'')}/${encodeURIComponent(pathPrefix)}`
451+
return `${(this.config.bucketMaskUrl || this.config.bucketUrl).replace(/\/*$/,'')}/${encodePath(pathPrefix)}`
447452
},
448453
validBucketPrefix(prefix) {
449454
if(prefix === '') return true
@@ -486,7 +491,7 @@ <h2 class="subtitle" v-html="config.subtitleHTML"></h2>
486491
bucketListApiUrl += `&max-keys=${config.pageSize}`
487492
}
488493
if (this.continuationToken) {
489-
bucketListApiUrl += `&continuation-token=${encodeURIComponent(this.continuationToken)}`
494+
bucketListApiUrl += `&continuation-token=${encodePath(this.continuationToken)}`
490495
}
491496
let listBucketResultResponse = await fetch(bucketListApiUrl)
492497
let listBucketResultXml = await listBucketResultResponse.text()
@@ -536,11 +541,11 @@ <h2 class="subtitle" v-html="config.subtitleHTML"></h2>
536541
}
537542
}
538543

539-
let url = `${(config.bucketMaskUrl || config.bucketUrl).replace(/\/*$/,'')}/${encodeURIComponent(content.key)}`
544+
let url = `${(config.bucketMaskUrl || config.bucketUrl).replace(/\/*$/,'')}/${encodePath(content.key)}`
540545
let installUrl = undefined
541546
if (url.endsWith('/manifest.plist') && devicePlatform_iOS()) {
542547
// generate manifest.plist install urls
543-
installUrl = `itms-services://?action=download-manifest&url=${encodeURIComponent(url)}`
548+
installUrl = `itms-services://?action=download-manifest&url=${encodePath(url)}`
544549
}
545550
return {
546551
type: 'content',

0 commit comments

Comments
 (0)