Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cribjs-editor
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
cribjs-editor
Commits
ed667023
Commit
ed667023
authored
Oct 02, 2020
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CribSWGadget: Check Crib Enable URL before setting it
* Also add the possibility to handle relative url
parent
4bd0ef76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
gadget/crib-sw-gadget.html
gadget/crib-sw-gadget.html
+5
-0
gadget/crib-sw-gadget.js
gadget/crib-sw-gadget.js
+22
-2
No files found.
gadget/crib-sw-gadget.html
View file @
ed667023
...
...
@@ -16,5 +16,10 @@
</head>
<body>
<div
class=
"storage-access"
style=
"display:none;"
></div>
<div
class=
"crib_enable_validator"
style=
"display:none;"
>
<div
data-gadget-url=
"./crib_enable_validator.html"
data-gadget-scope=
"crib_enable_validator"
data-gadget-sandbox=
"public"
></div>
</div>
</body>
</html>
\ No newline at end of file
gadget/crib-sw-gadget.js
View file @
ed667023
/*global window, rJS, RSVP, Blob, console */
/*global window, rJS, RSVP, Blob, console
, URL
*/
/*jslint indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
jIO
)
{
"
use strict
"
;
...
...
@@ -50,6 +50,15 @@
});
}
function
isValidUrl
(
string
)
{
try
{
new
URL
(
string
);
}
catch
(
_
)
{
return
false
}
return
true
;
}
rJS
(
window
)
.
ready
(
function
(
g
)
{
g
.
props
=
{};
...
...
@@ -121,9 +130,20 @@
})
.
declareMethod
(
'
setCribEnableGadgetUrl
'
,
function
(
url
)
{
var
gadget
=
this
;
// XXX Should perform checks
if
(
!
isValidUrl
(
url
))
{
url
=
new
URL
(
url
,
window
.
location
.
href
).
href
;
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
"
crib_enable_validator
"
);
})
.
push
(
function
(
validator_gadget
)
{
return
validator_gadget
.
validateCribEnableGadgetUrl
(
url
);
})
.
push
(
function
(
result
)
{
if
(
!
result
)
{
throw
"
Could not Validate CribJS Gadget URL:
"
+
url
;
}
return
gadget
.
setSetting
(
"
site_editor_gadget_url
"
,
url
);
})
.
push
(
function
()
{
...
...
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