Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
3bae7155
Unverified
Commit
3bae7155
authored
Jul 4, 2023
by
Adam Setch
Committed by
GitHub
Jul 4, 2023
Browse files
Options
Downloads
Patches
Plain Diff
refactor(release-notes): use util/url to validate url (#23128)
parent
81eb17aa
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/workers/repository/update/pr/changelog/release-notes.ts
+3
-15
3 additions, 15 deletions
lib/workers/repository/update/pr/changelog/release-notes.ts
with
3 additions
and
15 deletions
lib/workers/repository/update/pr/changelog/release-notes.ts
+
3
−
15
View file @
3bae7155
// TODO #7154
import
URL
from
'
node:url
'
;
import
is
from
'
@sindresorhus/is
'
;
import
is
from
'
@sindresorhus/is
'
;
import
{
DateTime
}
from
'
luxon
'
;
import
{
DateTime
}
from
'
luxon
'
;
import
MarkdownIt
from
'
markdown-it
'
;
import
MarkdownIt
from
'
markdown-it
'
;
...
@@ -9,6 +7,7 @@ import * as packageCache from '../../../../../util/cache/package';
...
@@ -9,6 +7,7 @@ import * as packageCache from '../../../../../util/cache/package';
import
{
detectPlatform
}
from
'
../../../../../util/common
'
;
import
{
detectPlatform
}
from
'
../../../../../util/common
'
;
import
{
linkify
}
from
'
../../../../../util/markdown
'
;
import
{
linkify
}
from
'
../../../../../util/markdown
'
;
import
{
newlineRegex
,
regEx
}
from
'
../../../../../util/regex
'
;
import
{
newlineRegex
,
regEx
}
from
'
../../../../../util/regex
'
;
import
{
validateUrl
}
from
'
../../../../../util/url
'
;
import
type
{
BranchUpgradeConfig
}
from
'
../../../../types
'
;
import
type
{
BranchUpgradeConfig
}
from
'
../../../../types
'
;
import
*
as
bitbucket
from
'
./bitbucket
'
;
import
*
as
bitbucket
from
'
./bitbucket
'
;
import
*
as
github
from
'
./github
'
;
import
*
as
github
from
'
./github
'
;
...
@@ -233,17 +232,6 @@ function sectionize(text: string, level: number): string[] {
...
@@ -233,17 +232,6 @@ function sectionize(text: string, level: number): string[] {
return
result
;
return
result
;
}
}
function
isUrl
(
url
:
string
):
boolean
{
try
{
return
!!
URL
.
parse
(
url
).
hostname
;
}
catch
(
err
)
{
// istanbul ignore next
logger
.
debug
({
err
},
`Error parsing
${
url
}
in URL.parse`
);
}
// istanbul ignore next
return
false
;
}
export
async
function
getReleaseNotesMdFileInner
(
export
async
function
getReleaseNotesMdFileInner
(
project
:
ChangeLogProject
project
:
ChangeLogProject
):
Promise
<
ChangeLogFile
|
null
>
{
):
Promise
<
ChangeLogFile
|
null
>
{
...
@@ -345,12 +333,12 @@ export async function getReleaseNotesMd(
...
@@ -345,12 +333,12 @@ export async function getReleaseNotesMd(
.
filter
(
Boolean
);
.
filter
(
Boolean
);
let
body
=
section
.
replace
(
regEx
(
/.*
?\n(
-
{3,}\n)?
/
),
''
).
trim
();
let
body
=
section
.
replace
(
regEx
(
/.*
?\n(
-
{3,}\n)?
/
),
''
).
trim
();
for
(
const
word
of
title
)
{
for
(
const
word
of
title
)
{
if
(
word
.
includes
(
version
)
&&
!
is
Url
(
word
))
{
if
(
word
.
includes
(
version
)
&&
!
validate
Url
(
word
))
{
logger
.
trace
({
body
},
'
Found release notes for v
'
+
version
);
logger
.
trace
({
body
},
'
Found release notes for v
'
+
version
);
// TODO: fix url
// TODO: fix url
const
notesSourceUrl
=
`
${
baseUrl
}${
repository
}
/blob/HEAD/
${
changelogFile
}
`
;
const
notesSourceUrl
=
`
${
baseUrl
}${
repository
}
/blob/HEAD/
${
changelogFile
}
`
;
const
mdHeadingLink
=
title
const
mdHeadingLink
=
title
.
filter
((
word
)
=>
!
is
Url
(
word
))
.
filter
((
word
)
=>
!
validate
Url
(
word
))
.
join
(
'
-
'
)
.
join
(
'
-
'
)
.
replace
(
regEx
(
/
[^
A-Za-z0-9-
]
/g
),
''
);
.
replace
(
regEx
(
/
[^
A-Za-z0-9-
]
/g
),
''
);
const
url
=
`
${
notesSourceUrl
}
#
${
mdHeadingLink
}
`
;
const
url
=
`
${
notesSourceUrl
}
#
${
mdHeadingLink
}
`
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment