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
d4e58a7b
Commit
d4e58a7b
authored
Jul 23, 2020
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Launcher route url when not at the root
parent
a0a68dd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
cribjs_launcher.js
cribjs_launcher.js
+26
-0
No files found.
cribjs_launcher.js
View file @
d4e58a7b
...
...
@@ -7,7 +7,33 @@
var
MAIN_SCOPE
=
"
m
"
;
function
validURL
(
str
)
{
var
pattern
=
new
RegExp
(
'
^(https?:
\\
/
\\
/)?
'
+
// protocol
'
((([a-z
\\
d]([a-z
\\
d-]*[a-z
\\
d])*)
\\
.)+[a-z]{2,}|
'
+
// domain name
'
((
\\
d{1,3}
\\
.){3}
\\
d{1,3}))
'
+
// OR ip (v4) address
'
(
\\
:
\\
d+)?(
\\
/[-a-z
\\
d%_.~+]*)*
'
+
// port and path
'
(
\\
?[;&a-z
\\
d%_.~+=-]*)?
'
+
// query string
'
(
\\
#[-a-z
\\
d_]*)?$
'
,
'
i
'
);
// fragment locator
return
!!
pattern
.
test
(
str
);
}
function
renderMainGadget
(
gadget
,
url
,
options
)
{
var
path
=
""
,
path_list
=
window
.
location
.
pathname
.
split
(
"
/
"
);
// If the url given is not a full url we add the current path
if
(
!
validURL
(
url
))
{
if
(
path_list
)
{
if
(
path_list
[
path_list
.
length
-
1
]
!==
""
)
{
if
(
path_list
[
path_list
.
length
-
1
].
endsWith
(
"
.html
"
))
{
path_list
[
path_list
.
length
-
1
]
=
""
;
}
else
{
path_list
.
push
(
""
);
}
}
path
=
path_list
.
join
(
"
/
"
);
}
url
=
path
+
url
;
url
=
url
.
replace
(
"
//
"
,
"
/
"
);
}
return
gadget
.
declareGadget
(
url
,
{
scope
:
MAIN_SCOPE
})
...
...
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