Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
rjs_json_form
Commits
3e6d462b
Commit
3e6d462b
authored
Jun 15, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'urn:jio:reference?' url schema supported
parent
59e8ced8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
6 deletions
+49
-6
jsonform.gadget.js
jsonform.gadget.js
+49
-6
No files found.
jsonform.gadget.js
View file @
3e6d462b
...
...
@@ -5,6 +5,36 @@
"
use strict
"
;
var
expandSchema
;
function
URLwithJio
(
url
,
base_url
)
{
var
urn_prefix
,
pathname
,
fake_prefix
=
"
https://jio_urn_prefix/
"
;
// XXX urn: can any case
if
(
url
.
startsWith
(
"
urn:jio:reference?
"
))
{
urn_prefix
=
url
.
indexOf
(
"
?
"
)
+
1
;
urn_prefix
=
url
.
slice
(
0
,
urn_prefix
);
url
=
fake_prefix
+
decodeURIComponent
(
url
.
replace
(
urn_prefix
,
""
));
}
if
(
typeof
base_url
===
"
string
"
&&
base_url
.
startsWith
(
"
urn:jio:reference?
"
))
{
if
(
!
urn_prefix
)
{
urn_prefix
=
base_url
.
indexOf
(
"
?
"
)
+
1
;
urn_prefix
=
base_url
.
slice
(
0
,
urn_prefix
);
}
base_url
=
fake_prefix
+
decodeURIComponent
(
base_url
.
replace
(
urn_prefix
,
""
));
}
url
=
new
URL
(
url
,
base_url
);
if
(
urn_prefix
)
{
pathname
=
url
.
pathname
.
slice
(
1
);
return
{
href
:
urn_prefix
+
encodeURIComponent
(
pathname
+
url
.
search
+
url
.
hash
),
origin
:
urn_prefix
,
pathname
:
encodeURIComponent
(
pathname
),
hash
:
url
.
hash
};
}
return
url
;
}
function
decodeJsonPointer
(
_str
)
{
// https://tools.ietf.org/html/rfc6901#section-5
return
_str
.
replace
(
/~1/g
,
'
/
'
).
replace
(
/~0/g
,
'
~
'
);
...
...
@@ -87,9 +117,9 @@
base_url
=
convertToRealWorldSchemaPath
(
g
,
path
),
absolute_url
;
if
(
base_url
===
""
||
base_url
.
indexOf
(
"
#
"
)
===
0
)
{
absolute_url
=
new
URL
(
url
,
base_url_failback
);
absolute_url
=
URLwithJio
(
url
,
base_url_failback
);
}
else
{
absolute_url
=
new
URL
(
url
,
base_url
);
absolute_url
=
URLwithJio
(
url
,
base_url
);
}
return
absolute_url
;
}
...
...
@@ -154,7 +184,8 @@
url
,
download_url
,
hash
,
schema_url_map
;
schema_url_map
,
queue
;
// XXX need use `id` property
if
(
!
path
)
{
path
=
"
/
"
;
...
...
@@ -179,7 +210,18 @@
}
hash
=
url
.
hash
;
url
=
url
.
href
;
return
downloadJSON
(
download_url
)
if
(
download_url
.
startsWith
(
"
urn:jio:
"
))
{
queue
=
RSVP
.
Queue
()
.
push
(
function
()
{
return
g
.
downloadJSON
(
download_url
);
});
}
else
{
queue
=
RSVP
.
Queue
()
.
push
(
function
()
{
return
downloadJSON
(
download_url
);
});
}
return
queue
.
push
(
function
(
json
)
{
checkCircular
(
g
,
path
,
url
);
return
resolveLocalReference
(
json
,
hash
);
...
...
@@ -192,9 +234,9 @@
schema_a
=
document
.
createElement
(
"
a
"
),
pointed_a
=
document
.
createElement
(
"
a
"
);
schema_a
.
setAttribute
(
"
href
"
,
download_url
);
schema_a
.
text
=
(
new
URL
(
download_url
)).
pathname
;
schema_a
.
text
=
(
URLwithJio
(
download_url
)).
pathname
;
pointed_a
.
setAttribute
(
"
href
"
,
url_from_pointed
);
pointed_a
.
text
=
(
new
URL
(
url_from_pointed
)).
pathname
;
pointed_a
.
text
=
(
URLwithJio
(
url_from_pointed
)).
pathname
;
g
.
props
.
schema_resolve_errors
[
url_from_pointed
]
=
{
schemaPath
:
path
,
message
:
[
...
...
@@ -373,6 +415,7 @@
g
.
props
=
{};
g
.
options
=
{};
})
.
declareAcquiredMethod
(
"
downloadJSON
"
,
"
downloadJSON
"
)
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
()
{
return
this
.
notifyChange
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment