Fix `decode_ultihash`, Lexer regexes. 33 examples, 7 failures
This commit is contained in:
parent
c10b809193
commit
f147830a45
|
@ -266,8 +266,12 @@ module Pigeon
|
|||
end
|
||||
|
||||
def self.decode_multihash(string)
|
||||
# "FEED.", "FILE.", "USER." etc..
|
||||
return b32_decode(string[5..])
|
||||
case string[0..4]
|
||||
when BLOB_SIGIL, MESSAGE_SIGIL, IDENTITY_SIGIL
|
||||
return b32_decode(string[5..])
|
||||
else
|
||||
return b32_decode(string)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,14 +56,14 @@ module Pigeon
|
|||
attr_reader :bundle_string, :scanner, :tokens
|
||||
# TODO: Change all the `{40,90}` values in ::Lexer to real values
|
||||
# TODO: Create regexes using string and Regexp.new() for cleaner regexes.
|
||||
ALPHANUMERICISH = /[a-zA-Z0-9_\-=\.]{1,90}/
|
||||
NUMERIC = /\d{1,7}/
|
||||
NULL_VALUE = /NONE/
|
||||
FEED_VALUE = /USER.{52}/
|
||||
MESG_VALUE = /TEXT.{52}/
|
||||
BLOB_VALUE = /FILE.{52}/
|
||||
FEED_VALUE = /USER\.[#{ALPHANUMERICISH}]{52}/
|
||||
MESG_VALUE = /TEXT\.[#{ALPHANUMERICISH}]{52}/
|
||||
BLOB_VALUE = /FILE\.[#{ALPHANUMERICISH}]{52}/
|
||||
STRG_VALUE = /".{1,128}"/
|
||||
# If you need other characters (but not spaces) submit an issue.
|
||||
ALPHANUMERICISH = /[a-zA-Z0-9_\-=\.\@\&]{1,90}/
|
||||
ALL_VALUES = [
|
||||
FEED_VALUE,
|
||||
MESG_VALUE,
|
||||
|
|
|
@ -86,7 +86,7 @@ RSpec.describe Pigeon::Lexer do
|
|||
expect(hash[:DEPTH]).to eq(message.depth)
|
||||
expect(hash[:KIND]).to eq(message.kind)
|
||||
expect(hash[:PREV]).to eq Pigeon::NOTHING
|
||||
expect(hash[:SIGNATURE]).to eq(messagenature)
|
||||
expect(hash[:SIGNATURE]).to eq(message.signature)
|
||||
end
|
||||
|
||||
it "catches syntax errors" do
|
||||
|
|
|
@ -52,7 +52,7 @@ RSpec.describe Pigeon::Message do
|
|||
"prev NONE",
|
||||
"",
|
||||
"a:\"bar\"",
|
||||
"b:&CHHABX8Q9D9Q0BY2BBZ6FA7SMAFNE9GGMSDTZVZZC9TK2N9F15QG.sha256",
|
||||
"b:FILE.CHHABX8Q9D9Q0BY2BBZ6FA7SMAFNE9GGMSDTZVZZC9TK2N9F15QG",
|
||||
"",
|
||||
"signature __SIGNATURE__",
|
||||
].join("\n")
|
||||
|
|
Loading…
Reference in New Issue