-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #793 from pauchan/pawel/update-url-transform
Allow URLTransform to accept custom character set
- Loading branch information
Showing
3 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// URLTransformTests.swift | ||
// ObjectMapper | ||
// | ||
// Created by pawel-rusin on 4/7/17. | ||
// Copyright © 2017 hearst. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import ObjectMapper | ||
|
||
class URLTransformTests: XCTestCase { | ||
|
||
func testUrlQueryAllowed() { | ||
let urlTransform = URLTransform() | ||
let input = "https://example.com/search?query=foo" | ||
let output = urlTransform.transformFromJSON(input) | ||
|
||
XCTAssertEqual(output, URL(string: "https://example.com/search?query=foo")) | ||
} | ||
|
||
func testCanPassInAllowedCharacterSet() { | ||
var characterSet = CharacterSet.urlQueryAllowed | ||
characterSet.insert(charactersIn: "%") | ||
let urlTransform = URLTransform(allowedCharacterSet: characterSet) | ||
let input = "https://example.com/%25" | ||
let output = urlTransform.transformFromJSON(input) | ||
|
||
XCTAssertEqual(output, URL(string: "https://example.com/%25")) | ||
} | ||
} |