lib/rmega/nodes/factory.rb in rmega-0.2.4 vs lib/rmega/nodes/factory.rb in rmega-0.2.5
- old
+ new
@@ -19,10 +19,13 @@
URL_REGEXP = /(http.:\/\/[w\.]*mega\.[a-z\.]+\/\#[A-Z0-9\_\-\!\=]+)/i
FOLDER_URL_REGEXP = /\#\F/
def url?(string)
- string.to_s =~ URL_REGEXP
+ return false unless string.to_s =~ URL_REGEXP
+ public_handle, key = string.strip.split('!')[1, 2]
+ return false if key and (Utils.base64urldecode(key) rescue nil).nil?
+ return true
end
def build(session, data)
type = Node::TYPES[data['t']].to_s
return Nodes.const_get(type.capitalize).new(session, data)