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
45f43023
Commit
45f43023
authored
4 years ago
by
Łukasz Groszkowski
Committed by
Phil Hughes
4 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added jest specs, rel, handle only http(s) in linkify, fix color
Credit goes to: @mrincon
parent
def87658
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
19 deletions
+89
-19
app/assets/javascripts/jobs/components/log/line.vue
app/assets/javascripts/jobs/components/log/line.vue
+26
-6
changelogs/unreleased/18324-add-links-to-urls-in-job-logs.yml
...gelogs/unreleased/18324-add-links-to-urls-in-job-logs.yml
+5
-0
package.json
package.json
+1
-0
spec/frontend/jobs/components/log/line_spec.js
spec/frontend/jobs/components/log/line_spec.js
+52
-13
yarn.lock
yarn.lock
+5
-0
No files found.
app/assets/javascripts/jobs/components/log/line.vue
View file @
45f43023
<
script
>
import
linkifyHtml
from
'
linkifyjs/html
'
;
import
{
sanitize
}
from
'
~/lib/dompurify
'
;
import
{
isAbsolute
}
from
'
~/lib/utils/url_utility
'
;
import
LineNumber
from
'
./line_number.vue
'
;
const
linkifyOptions
=
{
attributes
:
{
// eslint-disable-next-line @gitlab/require-i18n-strings
rel
:
'
nofollow noopener
'
,
},
className
:
'
gl-reset-color!
'
,
defaultProtocol
:
'
https
'
,
validate
:
{
email
:
false
,
url
(
value
)
{
return
isAbsolute
(
value
);
},
},
};
export
default
{
functional
:
true
,
props
:
{
...
...
@@ -17,13 +35,15 @@ export default {
const
{
line
,
path
}
=
props
;
const
chars
=
line
.
content
.
map
(
content
=>
{
return
h
(
'
span
'
,
{
const
linkfied
=
linkifyHtml
(
content
.
text
,
linkifyOptions
);
return
h
(
'
span
'
,
{
class
:
[
'
gl-white-space-pre-wrap
'
,
content
.
style
],
domProps
:
{
innerHTML
:
sanitize
(
linkfied
,
{
ALLOWED_TAGS
:
[
'
a
'
],
}),
},
content
.
text
,
);
});
});
return
h
(
'
div
'
,
{
class
:
'
js-line log-line
'
},
[
...
...
This diff is collapsed.
Click to expand it.
changelogs/unreleased/18324-add-links-to-urls-in-job-logs.yml
0 → 100644
View file @
45f43023
---
title
:
Make URL links in job logs clickable
merge_request
:
40175
author
:
Łukasz Groszkowski @falxcerebri
type
:
added
This diff is collapsed.
Click to expand it.
package.json
View file @
45f43023
...
...
@@ -106,6 +106,7 @@
"
jszip
"
:
"
^3.1.3
"
,
"
jszip-utils
"
:
"
^0.0.2
"
,
"
katex
"
:
"
^0.10.0
"
,
"
linkifyjs
"
:
"
^2.1.9
"
,
"
lodash
"
:
"
^4.17.20
"
,
"
marked
"
:
"
^0.3.12
"
,
"
mermaid
"
:
"
^8.5.2
"
,
...
...
This diff is collapsed.
Click to expand it.
spec/frontend/jobs/components/log/line_spec.js
View file @
45f43023
...
...
@@ -2,21 +2,25 @@ import { shallowMount } from '@vue/test-utils';
import
Line
from
'
~/jobs/components/log/line.vue
'
;
import
LineNumber
from
'
~/jobs/components/log/line_number.vue
'
;
describe
(
'
Job Log Line
'
,
()
=>
{
let
wrapper
;
const
httpUrl
=
'
http://example.com
'
;
const
httpsUrl
=
'
https://example.com
'
;
const
data
=
{
const
mockProps
=
({
text
=
'
Running with gitlab-runner 12.1.0 (de7731dd)
'
}
=
{})
=>
(
{
line
:
{
content
:
[
{
text
:
'
Running with gitlab-runner 12.1.0 (de7731dd)
'
,
text
,
style
:
'
term-fg-l-green
'
,
},
],
lineNumber
:
0
,
},
path
:
'
/jashkenas/underscore/-/jobs/335
'
,
};
});
describe
(
'
Job Log Line
'
,
()
=>
{
let
wrapper
;
let
data
;
const
createComponent
=
(
props
=
{})
=>
{
wrapper
=
shallowMount
(
Line
,
{
...
...
@@ -27,6 +31,7 @@ describe('Job Log Line', () => {
};
beforeEach
(()
=>
{
data
=
mockProps
();
createComponent
(
data
);
});
...
...
@@ -45,4 +50,38 @@ describe('Job Log Line', () => {
it
(
'
renders the provided style as a class attribute
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
span
'
).
classes
()).
toContain
(
data
.
line
.
content
[
0
].
style
);
});
describe
(
'
when the line contains a link
'
,
()
=>
{
const
findLink
=
()
=>
wrapper
.
find
(
'
span a
'
);
it
(
'
renders an http link
'
,
()
=>
{
createComponent
(
mockProps
({
text
:
httpUrl
}));
expect
(
findLink
().
text
()).
toBe
(
httpUrl
);
expect
(
findLink
().
attributes
().
href
).
toEqual
(
httpUrl
);
});
it
(
'
renders an https link
'
,
()
=>
{
createComponent
(
mockProps
({
text
:
httpsUrl
}));
expect
(
findLink
().
text
()).
toBe
(
httpsUrl
);
expect
(
findLink
().
attributes
().
href
).
toEqual
(
httpsUrl
);
});
it
(
'
renders a link with rel nofollow and noopener
'
,
()
=>
{
createComponent
(
mockProps
({
text
:
httpsUrl
}));
expect
(
findLink
().
attributes
().
rel
).
toBe
(
'
nofollow noopener
'
);
});
test
.
each
`
type | text
${
'
ftp
'
}
|
${
'
ftp://example.com/file
'
}
${
'
email
'
}
|
${
'
email@example.com
'
}
${
'
no scheme
'
}
|
${
'
example.com/page
'
}
`
(
'
does not render a $type link
'
,
({
text
})
=>
{
createComponent
(
mockProps
({
text
}));
expect
(
findLink
().
exists
()).
toBe
(
false
);
});
});
});
This diff is collapsed.
Click to expand it.
yarn.lock
View file @
45f43023
...
...
@@ -7602,6 +7602,11 @@ linkify-it@^2.0.0:
dependencies:
uc.micro "^1.0.1"
linkifyjs@^2.1.9:
version "2.1.9"
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-2.1.9.tgz#af06e45a2866ff06c4766582590d098a4d584702"
integrity sha512-74ivurkK6WHvHFozVaGtQWV38FzBwSTGNmJolEgFp7QgR2bl6ArUWlvT4GcHKbPe1z3nWYi+VUdDZk16zDOVug==
load-json-file@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0"
...
...
This diff is collapsed.
Click to expand it.
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