Skip to content

Commit

Permalink
Merge pull request timber#2220 from hatto/master
Browse files Browse the repository at this point in the history
Extending for Google Storage
  • Loading branch information
jarednova authored Apr 6, 2020
2 parents 2fb2609 + 2cfc7a2 commit 11ef08a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/URLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static function get_rel_path( $src ) {
*/
public static function remove_double_slashes( $url ) {
$url = str_replace('//', '/', $url);
$schemes_whitelist = array( 'http', 'https', 's3' );
$schemes_whitelist = apply_filters( 'timber/url/schemes-whitelist', array( 'http', 'https', 's3', 'gs' ) );
foreach ( $schemes_whitelist as $scheme ) {
if ( strstr($url, $scheme . ':') && !strstr($url, $scheme . '://') ) {
$url = str_replace( $scheme . ':/', $scheme . '://', $url );
Expand Down
7 changes: 7 additions & 0 deletions tests/test-timber-url-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ function testDoubleSlashesWithS3() {
$url = Timber\URLHelper::remove_double_slashes($url);
$this->assertEquals($expected_url, $url);
}

function testDoubleSlashesWithGS() {
$url = 'gs://bucket/folder//thing.html';
$expected_url = 'gs://bucket/folder/thing.html';
$url = Timber\URLHelper::remove_double_slashes($url);
$this->assertEquals($expected_url, $url);
}

function testUserTrailingSlashItFailure() {
$link = 'http:///example.com';
Expand Down

0 comments on commit 11ef08a

Please sign in to comment.