Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bb53f55d
Commit
bb53f55d
authored
Jan 13, 2021
by
Miguel Rincon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use gon.gitlab_url to create absolute path
parent
ef3b8cd5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
app/assets/javascripts/editor/extensions/editor_ci_schema_ext.js
...ets/javascripts/editor/extensions/editor_ci_schema_ext.js
+6
-8
spec/frontend/editor/editor_ci_schema_ext_spec.js
spec/frontend/editor/editor_ci_schema_ext_spec.js
+10
-0
No files found.
app/assets/javascripts/editor/extensions/editor_ci_schema_ext.js
View file @
bb53f55d
...
...
@@ -17,20 +17,18 @@ export class CiSchemaExtension extends EditorLiteExtension {
* @param {String?} opts.ref - Current ref. Defaults to master
*/
registerCiSchema
({
projectNamespace
,
projectPath
,
ref
=
'
master
'
}
=
{})
{
const
ciSchema
Uri
=
Api
.
buildUrl
(
Api
.
projectFileSchemaPath
)
const
ciSchema
Path
=
Api
.
buildUrl
(
Api
.
projectFileSchemaPath
)
.
replace
(
'
:namespace_path
'
,
projectNamespace
)
.
replace
(
'
:project_path
'
,
projectPath
)
.
replace
(
'
:ref
'
,
ref
)
.
replace
(
'
:filename
'
,
EXTENSION_CI_SCHEMA_FILE_NAME_MATCH
);
const
modelFileName
=
this
.
getModel
().
uri
.
path
.
split
(
'
/
'
).
pop
();
// In order for workers loaded from `data://` as the
// ones loaded by monaco
, we use absolute URLs to fetch
//
schema files, hence the `location.origin` reference.
// This prevents error:
// ones loaded by monaco
editor, we use absolute URLs
//
to fetch schema files, hence the `gon.gitlab_url`
//
reference.
This prevents error:
// "Failed to execute 'fetch' on 'WorkerGlobalScope'"
// eslint-disable-next-line no-restricted-globals
const
absoluteSchemaUrl
=
location
.
origin
+
ciSchemaUri
;
const
absoluteSchemaUrl
=
gon
.
gitlab_url
+
ciSchemaPath
;
const
modelFileName
=
this
.
getModel
().
uri
.
path
.
split
(
'
/
'
).
pop
()
;
registerSchema
({
uri
:
absoluteSchemaUrl
,
...
...
spec/frontend/editor/editor_ci_schema_ext_spec.js
View file @
bb53f55d
...
...
@@ -10,6 +10,7 @@ describe('~/editor/editor_ci_config_ext', () => {
let
editor
;
let
instance
;
let
editorEl
;
let
originalGitlabUrl
;
const
createMockEditor
=
({
blobPath
=
defaultBlobPath
}
=
{})
=>
{
setFixtures
(
'
<div id="editor"></div>
'
);
...
...
@@ -23,6 +24,15 @@ describe('~/editor/editor_ci_config_ext', () => {
instance
.
use
(
new
CiSchemaExtension
());
};
beforeAll
(()
=>
{
originalGitlabUrl
=
gon
.
gitlab_url
;
gon
.
gitlab_url
=
TEST_HOST
;
});
afterAll
(()
=>
{
gon
.
gitlab_url
=
originalGitlabUrl
;
});
beforeEach
(()
=>
{
createMockEditor
();
});
...
...
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