Skip to content

Conversation

@danieleggert
Copy link
Contributor

This fixes #1269

This uses try! Regex("…") instead of RegexBuilder to create regular expressions used by the URL Template implementation.

@itingliu
Copy link
Contributor

@swift-ci please test

}
}
}
self.operatorRegex = try! Regex(#"([\+#.\/;\?&])?"#)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if it makes a difference whether you create a Regex this way or the other one that specifies the output type?

init(
    _ pattern: String,
    as outputType: Output.Type = Output.self
) throws

For example would it help the performance since we can bypass parsing the result from AnyOutputRegex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea if that makes any difference. Happy to change it, if that helps. These are only every created once, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this as-is for now. We can always come back if we find this useful later.

@itingliu
Copy link
Contributor

itingliu commented May 5, 2025

@danieleggert Can you rebase to resolve the merge conflict?

@danieleggert
Copy link
Contributor Author

@jrflat Did I merge the changes correctly from your 876aa1f ?


// MARK: -

@available(FoundationPreview 6.2, *)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this annotation is needed since URL.Template.Element is an internal type, but otherwise LGTM!

@itingliu
Copy link
Contributor

@swift-ci please test

}
}
}
self.operatorRegex = try! Regex(#"([\+#.\/;\?&])?"#)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this as-is for now. We can always come back if we find this useful later.

@itingliu itingliu merged commit 88f6454 into swiftlang:main May 13, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make URI template's regex parsing available in swift-foundation

3 participants