Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F21907371
uri_helper.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
877 B
Referenced Files
None
Subscribers
None
uri_helper.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Helpers.UriHelper
do
def
modify_uri_params
(
uri
,
overridden_params
,
deleted_params
\\
[])
do
uri
=
URI
.
parse
(
uri
)
existing_params
=
URI
.
query_decoder
(
uri
.
query
||
""
)
|>
Map
.
new
()
overridden_params
=
Map
.
new
(
overridden_params
,
fn
{
k
,
v
}
->
{
to_string
(
k
),
v
}
end
)
deleted_params
=
Enum
.
map
(
deleted_params
,
&
to_string
/
1
)
updated_params
=
existing_params
|>
Map
.
merge
(
overridden_params
)
|>
Map
.
drop
(
deleted_params
)
uri
|>
Map
.
put
(
:query
,
URI
.
encode_query
(
updated_params
))
|>
URI
.
to_string
()
|>
String
.
replace_suffix
(
"?"
,
""
)
end
def
maybe_add_base
(
"/"
<>
uri
,
base
),
do
:
Path
.
join
([
base
,
uri
])
def
maybe_add_base
(
uri
,
_base
),
do
:
uri
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sun, Dec 28, 1:41 AM (16 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
764725
Default Alt Text
uri_helper.ex (877 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment