Skip to content

Commit

Permalink
improve datalink uri handling to consider : inside uri
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Mar 30, 2022
1 parent 6368409 commit 4433a21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/random_json_joke.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% web. In the below example, the jokeapi.dev feed returns a JSON record via
% RESTFul URL, the returned record contains a subfield called `joke`, which
% can be retrieved via the JSONPath $.joke attched after the URL, separated
% by a collon. The general _DataLink_ URL is in the form of "URL:$jsonpath"
% by a colon. The general _DataLink_ URL is in the form of "URL:$jsonpath"

if(nargin==0)
num=1;
Expand Down
6 changes: 5 additions & 1 deletion jdatadecode.m
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,11 @@
if(opt.maxlinklevel>0 && isfield(data,N_('_DataLink_')))
if(ischar(data.(N_('_DataLink_'))))
datalink=data.(N_('_DataLink_'));
ref=regexp(datalink, '^(?<proto>[a-zA-Z]+://)*(?<path>.+)(?<delim>\:)()*(?<jsonpath>(?<=:)\$\d*\..*)*', 'names');
if(regexp(datalink,'\:\$'))
ref=regexp(datalink, '^(?<proto>[a-zA-Z]+://)*(?<path>.+)(?<delim>\:)()*(?<jsonpath>(?<=:)\$\d*\.*.*)*', 'names');
else
ref=regexp(datalink, '^(?<proto>[a-zA-Z]+://)*(?<path>.+)(?<delim>\:)*(?<jsonpath>(?<=:)\$\d*\..*)*', 'names');
end
if(~isempty(ref.path))
uripath=[ref.proto ref.path];
[fpath, fname, fext]=fileparts(uripath);
Expand Down

0 comments on commit 4433a21

Please sign in to comment.