sanitize_embed_url

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

Type:
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:

-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.

Edit on GitHub