# observe\_sanitize\_embed\_url/2

Source: https://zotonic.com/docs/1807/observe_sanitize_embed_url-2

URI: https://zotonic.com/id/1807

Language: en



Sanitize an embed url. The hostpart is of the format: `<<"youtube.com/v...">>`.

Type:

[first](/id/doc_developerguide_notifications#notification-first)

Return:

`undefined`, `false` or a binary with a acceptable hostpath

`#sanitize_embed_url{}` properties:

- hostpath: `binary`

This notification is used to sanitize *embed urls* passed with the media import routines.

Example usage in a module, where URLs from some public broadcasters are allowed:

```erlang
-export([
    observe_sanitize_embed_url/2
]).

observe_sanitize_embed_url(#sanitize_embed_url{hostpath= <<"media.vara.nl/", _/binary>> = Url}, _Context) ->
    Url;
observe_sanitize_embed_url(#sanitize_embed_url{hostpath= <<"biografie.vara.nl/", _/binary>> = Url}, _Context) ->
    Url;
observe_sanitize_embed_url(#sanitize_embed_url{hostpath= <<"js.vpro.nl/", _/binary>> = Url}, _Context) ->
    Url;
observe_sanitize_embed_url(#sanitize_embed_url{hostpath= <<"embed.vpro.nl/", _/binary>> = Url}, _Context) ->
    Url;
observe_sanitize_embed_url(_, _Context) ->
    undefined.
```

Note the `undefined` returned if no other patterns match. This allows other modules to check for different patterns.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1807?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1807?language=en>)
