-
Notifications
You must be signed in to change notification settings - Fork 7
FQN: Add support for special characters #199
Conversation
* Support special characters in FQNs like "." and "/" and correctly parse them from the URL using URL encoding and a special Unison specific encoding with ";." for ".". * Also update the namespace/definition url separator from "/-/" to "/;/". * Add a bunch of parser test coverage.
go z | ||
|
||
x :: y -> | ||
x :: go y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapted from the Haskell implementation
urlDecode s = | ||
-- Let invalid % encoding fall through, since it then must be valid | ||
-- strings | ||
Maybe.withDefault s (Url.percentDecode s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
percentDecode
seems a bit strange to me in that it fails if it encounters a % not followed by valid encoding characters. That kind of configuration are still valid URLs though.
@@ -161,7 +161,7 @@ hashQualifiedFromString sep str = | |||
|
|||
name_ :: unprefixedHash :: [] -> | |||
Hash.fromString (Hash.prefix ++ unprefixedHash) | |||
|> Maybe.map (HashQualified (FQN.fromString name_)) | |||
|> Maybe.map (HashQualified (toFQN name_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug; we were never passing this through a URL encoder.
-- ';' as the separator character between namespace FQNs and | ||
-- definition FQNs. (';' is not a valid character in FQNs and is | ||
-- safe as a separator/escape character). | ||
[ b (succeed (identity ".") |. s ";.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having this special case here didn't feel great, but was the simplest when chomping deals with character to character which would lead to a clash with /;/
(the namespace/definition separator).
@pchiusano when you have a moment, i'd love your eyes on this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me but LMK if you were looking for an opinion on anything in particular.
Overview
"."
and"/"
and correctly parsethem from the URL using URL encoding and a special Unison specific
encoding with
";."
for"."
."/-/"
to"/;/"
.This fixes #196