Skip to content

Commit dd13ed0

Browse files
Alex Martsinovichmartosaur
authored andcommitted
Add migration guide
1 parent 0b4eb98 commit dd13ed0

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

guides/migrating_to_1.0.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Migrating from 0.3 to 1.0
2+
3+
### Replace `SafeURL.get/4` with `SafeURL.HTTPoison.get/3`
4+
5+
`SafeURL.get/4` has been replaced with `SafeURL.HTTPoison.get/3`. It is now a
6+
drop-in replacement for `HTTPoison.get/3` and thus does not support passing
7+
`SafeURL` options through function arguments.
8+
9+
### Account for new error messages or use `:detailed_error` option
10+
11+
`SafeURL.validate/2` now returns a more specific error by default:
12+
13+
```elixir
14+
iex> SafeURL.validate("http://localhost")
15+
{:error, :unsafe_reserved}
16+
iex> SafeURL.validate("http://google.com", schemes: [:https])
17+
{:error, :unsafe_scheme}
18+
```
19+
20+
You can use the `:detailed_error` configuration option to restore the previous
21+
behavior and get the generic `{:error, :restricted}` error:
22+
23+
```elixir
24+
iex> SafeURL.validate("http://localhost", detailed_error: false)
25+
{:error, :restricted}
26+
iex> Application.put_env(:safeurl, :detailed_error, false)
27+
:ok
28+
iex> SafeURL.validate("http://localhost")
29+
{:error, :restricted}
30+
```

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule SafeURL.MixProject do
2424
source_url: @github,
2525
homepage_url: @github,
2626
canonical: "https://hexdocs.pm/#{@app}",
27-
extras: ["README.md"]
27+
extras: ["README.md", "guides/migrating_to_1.0.md"]
2828
]
2929
]
3030
end

0 commit comments

Comments
 (0)