Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
b04e001d
Unverified
Commit
b04e001d
authored
Nov 28, 2022
by
boojack
Committed by
GitHub
Nov 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: image url host missing (#623)
parent
fbe7b604
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
utils.ts
web/src/helpers/utils.ts
+6
-0
Image.ts
web/src/labs/marked/parser/Image.ts
+3
-1
No files found.
web/src/helpers/utils.ts
View file @
b04e001d
...
...
@@ -134,3 +134,9 @@ export const parseHTMLToRawText = (htmlStr: string): string => {
const
text
=
tempEl
.
innerText
;
return
text
;
};
export
function
absolutifyLink
(
rel
:
string
):
string
{
const
anchor
=
document
.
createElement
(
"a"
);
anchor
.
setAttribute
(
"href"
,
rel
);
return
anchor
.
href
;
}
web/src/labs/marked/parser/Image.ts
View file @
b04e001d
import
{
escape
}
from
"lodash-es"
;
import
{
absolutifyLink
}
from
"../../../helpers/utils"
;
export
const
IMAGE_REG
=
/!
\[
.*
?\]\((
.+
?)\)
/
;
...
...
@@ -8,8 +9,9 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
}
const
imageUrl
=
absolutifyLink
(
escape
(
matchResult
[
1
]));
// NOTE: Get image blob from backend to avoid CORS.
return
`<img class='img' src='/o/get/image?url=
${
escape
(
matchResult
[
1
])
}
' />`
;
return
`<img class='img' src='/o/get/image?url=
${
imageUrl
}
' />`
;
};
export
default
{
...
...
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