Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
9f84b43f
Commit
9f84b43f
authored
May 25, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
May 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate url module to TS
parent
7ff6ebdb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
12 deletions
+6
-12
url.ts
src/sidebar/util/url.ts
+6
-12
No files found.
src/sidebar/util/url.
j
s
→
src/sidebar/util/url.
t
s
View file @
9f84b43f
...
@@ -8,15 +8,12 @@ import { hasOwn } from '../../shared/has-own';
...
@@ -8,15 +8,12 @@ import { hasOwn } from '../../shared/has-own';
*
*
* replaceURLParams('/things/:id', {id: 'foo', q: 'bar'}) =>
* replaceURLParams('/things/:id', {id: 'foo', q: 'bar'}) =>
* {url: '/things/foo', unusedParams: {q: 'bar'}}
* {url: '/things/foo', unusedParams: {q: 'bar'}}
*
* @template Param
* @param {string} url
* @param {Record<string, Param>} params
* @return {{ url: string, unusedParams: Record<string, Param>}}
*/
*/
export
function
replaceURLParams
(
url
,
params
)
{
export
function
replaceURLParams
<
Param
>
(
/** @type {Record<string, Param>} */
url
:
string
,
const
unusedParams
=
{};
params
:
Record
<
string
,
Param
>
):
{
url
:
string
;
unusedParams
:
Record
<
string
,
Param
>
}
{
const
unusedParams
:
Record
<
string
,
Param
>
=
{};
for
(
const
param
in
params
)
{
for
(
const
param
in
params
)
{
if
(
hasOwn
(
params
,
param
))
{
if
(
hasOwn
(
params
,
param
))
{
const
value
=
params
[
param
];
const
value
=
params
[
param
];
...
@@ -33,10 +30,7 @@ export function replaceURLParams(url, params) {
...
@@ -33,10 +30,7 @@ export function replaceURLParams(url, params) {
/**
/**
* Resolve a relative URL against a base URL to get an absolute URL.
* Resolve a relative URL against a base URL to get an absolute URL.
*
* @param {string} relativeURL
* @param {string} baseURL
*/
*/
export
function
resolve
(
relativeURL
,
baseURL
)
{
export
function
resolve
(
relativeURL
:
string
,
baseURL
:
string
):
string
{
return
new
URL
(
relativeURL
,
baseURL
).
href
;
return
new
URL
(
relativeURL
,
baseURL
).
href
;
}
}
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