Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MIME Normalizer
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
JS Toolbox
MIME Normalizer
Commits
0f9c6f30
Commit
0f9c6f30
authored
4 years ago
by
Igor Markin
Browse files
Options
Downloads
Patches
Plain Diff
Add build
parent
519f962e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!13
Use url parse
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dist/HTMLNormalizer/strategies/common.js
+4
-3
4 additions, 3 deletions
dist/HTMLNormalizer/strategies/common.js
dist/PlainNormalizer/PlainNormalizer.js
+4
-2
4 additions, 2 deletions
dist/PlainNormalizer/PlainNormalizer.js
with
8 additions
and
5 deletions
dist/HTMLNormalizer/strategies/common.js
+
4
−
3
View file @
0f9c6f30
"
use strict
"
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
cloneAnchorFromPane
=
exports
.
pruneElement
=
exports
.
amendNodes
=
exports
.
ATTRIBUTES_TO_KEEP
=
exports
.
ELEMENT_TYPES_TO_REMOVE
=
void
0
;
const
url_parse_1
=
require
(
"
url-parse
"
);
// this is a Node module. require is a must to work across different envs
const
URL
=
require
(
"
url-parse
"
);
const
DUMMY_QR_CODE_ID
=
"
dummyQrCode
"
;
exports
.
ELEMENT_TYPES_TO_REMOVE
=
{
br
:
true
,
...
...
@@ -24,7 +25,7 @@ const amendNodes = (document) => {
*/
const
anchors
=
document
.
getElementsByTagName
(
"
a
"
);
for
(
const
anchor
of
anchors
)
{
const
url
=
new
url_parse_1
.
default
(
anchor
.
getAttribute
(
"
href
"
),
true
);
const
url
=
new
URL
(
anchor
.
getAttribute
(
"
href
"
),
true
);
if
(
url
.
host
.
includes
(
"
safelinks.protection.outlook.com
"
))
{
anchor
.
setAttribute
(
"
href
"
,
url
.
query
[
"
url
"
]);
}
...
...
@@ -53,7 +54,7 @@ const pruneElement = (element) => {
exports
.
pruneElement
=
pruneElement
;
const
cloneAnchorFromPane
=
(
a
,
pane
)
=>
{
try
{
const
url
=
new
url_parse_1
.
default
(
a
.
getAttribute
(
"
href
"
));
const
url
=
new
URL
(
a
.
getAttribute
(
"
href
"
));
// If this is external url
if
(
url
.
host
&&
url
.
protocol
)
{
pane
.
parentNode
.
insertBefore
(
a
.
cloneNode
(
false
),
pane
);
...
...
This diff is collapsed.
Click to expand it.
dist/PlainNormalizer/PlainNormalizer.js
+
4
−
2
View file @
0f9c6f30
"
use strict
"
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
normalizePlainPart
=
void
0
;
// this is a Node module. require is a must to work across different envs
const
URL
=
require
(
"
url-parse
"
);
const
utils_1
=
require
(
"
../utils
"
);
const
normalizePlainPart
=
(
text
)
=>
{
text
=
removeListBullets
(
text
);
...
...
@@ -13,8 +15,8 @@ const patchOutlookSafelinksWrappers = (text) => {
const
links
=
text
.
match
(
/<https:.+
?(
safelinks
\.
protection
\.
outlook
\.
com
)
.+
?
>/g
);
if
(
links
)
{
links
.
forEach
((
link
)
=>
{
const
url
=
new
URL
(
link
.
slice
(
1
,
link
.
length
-
1
));
const
originalUrl
=
url
.
searchParams
.
get
(
"
url
"
)
;
const
url
=
new
URL
(
link
.
slice
(
1
,
link
.
length
-
1
)
,
true
);
const
originalUrl
=
url
.
query
[
"
url
"
]
;
text
=
text
.
replace
(
link
,
`<
${
originalUrl
}
>`
);
});
}
...
...
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