Skip to content

Parsing Fragment #97

Closed Answered by robfeldmann
ker0beros asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ker0beros,

Not sure if you've solved this issue or not. You are using an extension on Route that is designed to return just the path component of a route:

let path = try? r.path(for: .privacyPolicy(section: "SECTION"))
                  

So in the above case the output you got would be expected (/legal/privacy).

Instead, you would want to print the route like this:

let data = try r.print(.privacyPolicy(section: "SECTION"))
                  

let url = URLComponents(data: data).url!
print(url.absoluteString) 
// prints: /legal/privacy#SECTION

Parsing your URL's fragment is a little bit more complex. Below is one way to do it:

  func testFragment() throws {
    struct Token: Equatable {

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ker0beros
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants