Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ docs
# can change it using the `--build-path` option.
.build
Packages

# SwiftPM manages xcode config via the `generate-xcodeproj` command
*.xcodeproj
xcuserdata
DerivedData/
491 changes: 0 additions & 491 deletions HypertextApplicationLanguage.xcodeproj/project.pbxproj

This file was deleted.

This file was deleted.

This file was deleted.

15 changes: 13 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// swift-tools-version:5.0
// HypertextApplicationLanguage Package.swift
//
// Copyright © 2017, Roy Ratcliffe, Pioneering Software, United Kingdom
Expand Down Expand Up @@ -26,7 +27,17 @@ import PackageDescription

let package = Package(
name: "HypertextApplicationLanguage",
exclude: [
"Tests/HypertextApplicationLanguageTests/Fixtures",
products: [
.library(name: "HypertextApplicationLanguage", targets: ["HypertextApplicationLanguage"])
],
targets: [
.target(name: "HypertextApplicationLanguage",
exclude: [
"Tests/HypertextApplicationLanguageTests/Fixtures",
]
),
.testTarget(name: "HypertextApplicationLanguageTests",
dependencies: ["HypertextApplicationLanguage"]
)
]
)
43 changes: 43 additions & 0 deletions Package@swift-4.0.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// swift-tools-version:4.0
// HypertextApplicationLanguage Package.swift
//
// Copyright © 2017, Roy Ratcliffe, Pioneering Software, United Kingdom
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the “Software”), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND, EITHER
// EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
//------------------------------------------------------------------------------

import PackageDescription

let package = Package(
name: "HypertextApplicationLanguage",
products: [
.library(name: "HypertextApplicationLanguage", targets: ["HypertextApplicationLanguage"])
],
targets: [
.target(name: "HypertextApplicationLanguage",
exclude: [
"Tests/HypertextApplicationLanguageTests/Fixtures",
]
),
.testTarget(name: "HypertextApplicationLanguageTests",
dependencies: ["HypertextApplicationLanguage"]
)
]
)
43 changes: 43 additions & 0 deletions Package@swift-4.2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// swift-tools-version:4.2
// HypertextApplicationLanguage Package.swift
//
// Copyright © 2017, Roy Ratcliffe, Pioneering Software, United Kingdom
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the “Software”), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND, EITHER
// EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
//------------------------------------------------------------------------------

import PackageDescription

let package = Package(
name: "HypertextApplicationLanguage",
products: [
.library(name: "HypertextApplicationLanguage", targets: ["HypertextApplicationLanguage"])
],
targets: [
.target(name: "HypertextApplicationLanguage",
exclude: [
"Tests/HypertextApplicationLanguageTests/Fixtures",
]
),
.testTarget(name: "HypertextApplicationLanguageTests",
dependencies: ["HypertextApplicationLanguage"]
)
]
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public struct Link {
// swiftlint:disable:next force_try
static let expression = try! NSRegularExpression(pattern: "\\{.+\\}", options: [])
}
let range = NSRange(location: 0, length: href.characters.count)
let range = NSRange(location: 0, length: href.count)
return Templated.expression.numberOfMatches(in: href, options: [], range: range) > 0
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public class NamespaceManager {
public func curie(href: String) -> String? {
for (name, ref) in refForName {
guard let range = ref.range(of: NamespaceManager.Rel) else { continue }
let left = ref.substring(to: range.lowerBound)
let right = ref.substring(from: range.upperBound)
let left = String(ref[..<range.lowerBound])
let right = String(ref[range.upperBound...])
let leftDistance = ref.distance(from: ref.startIndex, to: range.lowerBound)
let rightDistance = ref.distance(from: range.upperBound, to: ref.endIndex)
let startIndex = href.index(href.startIndex, offsetBy: leftDistance)
let endIndex = href.index(href.endIndex, offsetBy: -rightDistance)
guard startIndex <= endIndex else { continue }
if href.substring(to: startIndex) == left && href.substring(from: endIndex) == right {
return name + ":" + href.substring(with: startIndex..<endIndex)
if String(href[..<startIndex]) == left && String(href[endIndex...]) == right {
return name + ":" + String(href[startIndex..<endIndex])
}
}
return nil
Expand All @@ -85,10 +85,10 @@ public class NamespaceManager {
/// works.
public func href(curie: String) -> String? {
guard let range = curie.range(of: ":") else { return nil }
let name = curie.substring(to: range.lowerBound)
let name = String(curie[..<range.lowerBound])
guard var ref = refForName[name] else { return nil }
guard let relRange = ref.range(of: NamespaceManager.Rel) else { return nil }
let arg = curie.substring(from: range.upperBound)
let arg = String(curie[range.upperBound...])
ref.replaceSubrange(relRange, with: arg)
return ref
}
Expand Down