Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
LuckySwap
interface
Commits
fd1aded5
Unverified
Commit
fd1aded5
authored
May 16, 2023
by
Vignesh Mohankumar
Committed by
GitHub
May 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remove trailing slash from request url (#6542)
* fix: remove trailing slash from request url * moves cast * {}
parent
27ad7cbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
errors.test.ts
src/tracing/errors.test.ts
+35
-0
errors.ts
src/tracing/errors.ts
+4
-0
No files found.
src/tracing/errors.test.ts
View file @
fd1aded5
...
@@ -10,6 +10,41 @@ Object.defineProperty(window.performance, 'getEntriesByType', {
...
@@ -10,6 +10,41 @@ Object.defineProperty(window.performance, 'getEntriesByType', {
describe
(
'
beforeSend
'
,
()
=>
{
describe
(
'
beforeSend
'
,
()
=>
{
const
ERROR
=
{}
as
ErrorEvent
const
ERROR
=
{}
as
ErrorEvent
describe
(
'
updateRequestUrl
'
,
()
=>
{
test
(
'
should remove "/#" from the request URL
'
,
()
=>
{
const
event
=
{
request
:
{
url
:
'
https://app.uniswap.org/#/example
'
,
},
}
as
ErrorEvent
beforeSend
(
event
,
{})
expect
(
event
.
request
?.
url
).
toBe
(
'
https://app.uniswap.org/example
'
)
})
test
(
'
should remove trailing slash from the request URL
'
,
()
=>
{
const
event
=
{
request
:
{
url
:
'
https://app.uniswap.org/example/
'
,
},
}
as
ErrorEvent
beforeSend
(
event
,
{})
expect
(
event
.
request
?.
url
).
toBe
(
'
https://app.uniswap.org/example
'
)
})
test
(
'
should not modify the request URL if no changes are required
'
,
()
=>
{
const
event
=
{
request
:
{
url
:
'
https://app.uniswap.org/example
'
,
},
}
as
ErrorEvent
beforeSend
(
event
,
{})
expect
(
event
.
request
?.
url
).
toBe
(
'
https://app.uniswap.org/example
'
)
})
})
describe
(
'
chunkResponseStatus
'
,
()
=>
{
describe
(
'
chunkResponseStatus
'
,
()
=>
{
afterEach
(()
=>
{
afterEach
(()
=>
{
jest
.
restoreAllMocks
()
jest
.
restoreAllMocks
()
...
...
src/tracing/errors.ts
View file @
fd1aded5
...
@@ -31,10 +31,14 @@ function isEthersRequestError(error: Error): error is Error & { requestBody: str
...
@@ -31,10 +31,14 @@ function isEthersRequestError(error: Error): error is Error & { requestBody: str
// Since the interface currently uses HashRouter, URLs will have a # before the path.
// Since the interface currently uses HashRouter, URLs will have a # before the path.
// This leads to issues when we send the URL into Sentry, as the path gets parsed as a "fragment".
// This leads to issues when we send the URL into Sentry, as the path gets parsed as a "fragment".
// Instead, this logic removes the # part of the URL.
// Instead, this logic removes the # part of the URL.
// It also removes trailing slashes, as they are not needed.
// See https://romain-clement.net/articles/sentry-url-fragments/#url-fragments
// See https://romain-clement.net/articles/sentry-url-fragments/#url-fragments
function
updateRequestUrl
(
event
:
ErrorEvent
)
{
function
updateRequestUrl
(
event
:
ErrorEvent
)
{
if
(
event
.
request
?.
url
)
{
if
(
event
.
request
?.
url
)
{
event
.
request
.
url
=
event
.
request
.
url
.
replace
(
'
/#
'
,
''
)
event
.
request
.
url
=
event
.
request
.
url
.
replace
(
'
/#
'
,
''
)
if
(
event
.
request
.
url
.
endsWith
(
'
/
'
))
{
event
.
request
.
url
=
event
.
request
.
url
.
slice
(
0
,
-
1
)
}
}
}
}
}
...
...
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