Skip to content

Commit

Permalink
Document allowedCharacters
Browse files Browse the repository at this point in the history
  • Loading branch information
onmyway133 committed Aug 16, 2017
1 parent 9523275 commit 1b4518e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Sources/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ struct PercentEncoder {

/// Perform url encoding
///
/// - Parameter allowedCharacters: Won't encode allowed characters
/// - Parameter string: The source string
/// - Returns: The encoded string
static func encode(string: String, allowed: String) -> String {
static func encode(string: String, allowedCharacters: String) -> String {
var set = CharacterSet.urlPathAllowed
allowed.unicodeScalars.forEach {
allowedCharacters.unicodeScalars.forEach {
set.insert($0)
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Compass/UtilitiesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import XCTest
class UtilitiesTests: XCTestCase {
func testEncode() {
let urn = "organization:hyper oslo:simply awesome"
let encodedUrn = PercentEncoder.encode(string: urn, allowed: ":")
let encodedUrn = PercentEncoder.encode(string: urn, allowedCharacters: ":")

XCTAssertEqual(encodedUrn, "organization:hyper%20oslo:simply%20awesome")
}

func testDecode() {
let urn = "organization:hyper oslo:simply awesome"
let encodedUrn = PercentEncoder.encode(string: urn, allowed: ":")
let encodedUrn = PercentEncoder.encode(string: urn, allowedCharacters: ":")

XCTAssertEqual(PercentEncoder.decode(string: encodedUrn), urn)
}
Expand Down

0 comments on commit 1b4518e

Please sign in to comment.