Skip to content

Commit

Permalink
Merge pull request #168 from contentful/bugfix/asset-url-scheme
Browse files Browse the repository at this point in the history
Debug https not being prepending to urls always
  • Loading branch information
loudmouth committed Jan 31, 2018
2 parents cea47b8 + 2645438 commit 12be385
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .env
@@ -1 +1 @@
CONTENTFUL_SDK_VERSION=1.0.0
CONTENTFUL_SDK_VERSION=1.0.1
2 changes: 1 addition & 1 deletion .envrc
@@ -1 +1 @@
export CONTENFUL_SDK_VERSION=1.0.0
export CONTENFUL_SDK_VERSION=1.0.1
10 changes: 9 additions & 1 deletion CHANGELOG.md
Expand Up @@ -10,7 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) starting from
## Table of contents

#### 1.x Releases
- `1.0.0` Releases - [1.0.0](#100)
- `1.0.0` Releases - [1.0.0](#100) | [1.0.1](#101)
- `1.0.0-betax` Releases - [1.0.0-beta1](#100-beta1) | [1.0.0-beta2](#100-beta2) | [1.0.0-beta3](#100-beta3) | [1.0.0-beta4](#100-beta4) | [1.0.0-beta5](#100-beta5)

#### 0.x Releases
Expand All @@ -26,6 +26,14 @@ This project adheres to [Semantic Versioning](http://semver.org/) starting from

---

## [`1.0.1`](https://github.com/contentful/contentful.swift/releases/tag/1.0.1)
Released on 2017-01-31

#### Fixed
- `String` extension to generate an image url that didn't always prepend the "https" scheme to the url.

---

## [`1.0.0`](https://github.com/contentful/contentful.swift/releases/tag/1.0.0)
Released on 2017-01-25

Expand Down
2 changes: 1 addition & 1 deletion Config.xcconfig
@@ -1 +1 @@
CONTENTFUL_SDK_VERSION=1.0.0
CONTENTFUL_SDK_VERSION=1.0.1
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -156,7 +156,7 @@ pod 'Contentful'
You can specify a specific version of Contentful depending on your needs. To learn more about operators for dependency versioning within a Podfile, see the [CocoaPods doc on the Podfile][7].

```ruby
pod 'Contentful', '~> 1.0.0'
pod 'Contentful', '~> 1.0.1'
```

Note that for Swift 3 support (contentful.swift versions [`0.3.0` - `0.9.3`]) you will need to add a post-install script to your Podfile if installing with Cocoapods:
Expand All @@ -176,7 +176,7 @@ end
You can also use [Carthage][8] for integration by adding the following to your `Cartfile`:

```
github "contentful/contentful.swift" ~> 1.0.0
github "contentful/contentful.swift" ~> 1.0.1
```

## License
Expand Down
17 changes: 14 additions & 3 deletions Sources/Contentful/Asset.swift
Expand Up @@ -8,13 +8,24 @@

import Foundation

public extension String {
internal extension String {

/**
Will make a `URL` from the current `String` instance if possible.
*/
public func url() throws -> URL {
guard let url = URL(string: self) else { throw SDKError.invalidURL(string: self) }
internal func url() throws -> URL {
guard var urlComponents = URLComponents(string: self) else {
throw SDKError.invalidURL(string: self)
}

// Append https scheme if not present.
if urlComponents.scheme == nil {
urlComponents.scheme = "https"
}

guard let url = urlComponents.url else {
throw SDKError.invalidURL(string: self)
}
return url
}
}
Expand Down
4 changes: 0 additions & 4 deletions Sources/Contentful/ImageOptions.swift
Expand Up @@ -63,10 +63,6 @@ public extension String {
throw SDKError.invalidURL(string: urlString)
}

if urlComponents.scheme == nil {
urlComponents.scheme = "https"
}

urlComponents.queryItems = try imageOptions.flatMap { option in
try option.urlQueryItems()
}
Expand Down

0 comments on commit 12be385

Please sign in to comment.