Skip to content
Snippets Groups Projects
Commit bec28a63 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

OEmbed: Improve meta tag parser

parent b328c000
No related branches found
No related tags found
No related merge requests found
......@@ -83,12 +83,22 @@ OEmbed.getUrlMeta = (url, withFragment) ->
if content?.body?
metas = {}
content.body.replace /<meta.*(?:name|property)=['"]([^'"]*)['"].*content=['"]([^'"]*)['"].*>/gmi, (meta, name, value) ->
content.body.replace /<title>(.+)<\/title>/gmi, (meta, title) ->
metas.pageTitle = title
content.body.replace /<meta[^>]*(?:name|property)=[']([^']*)['][^>]*content=[']([^']*)['][^>]*>/gmi, (meta, name, value) ->
metas[changeCase.camelCase(name)] = value
content.body.replace /<meta[^>]*(?:name|property)=["]([^"]*)["][^>]*content=["]([^"]*)["][^>]*>/gmi, (meta, name, value) ->
metas[changeCase.camelCase(name)] = value
content.body.replace /<meta.*content=['"]([^'"]*)['"].*(?:name|property)=['"]([^'"]*)['"].*>/gmi, (meta, name, value) ->
content.body.replace /<meta[^>]*content=[']([^']*)['][^>]*(?:name|property)=[']([^']*)['][^>]*>/gmi, (meta, value, name) ->
metas[changeCase.camelCase(name)] = value
content.body.replace /<meta[^>]*content=["]([^"]*)["][^>]*(?:name|property)=["]([^"]*)["][^>]*>/gmi, (meta, value, name) ->
metas[changeCase.camelCase(name)] = value
if metas.fragment is '!' and not withFragment?
return OEmbed.getUrlMeta url, true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment