mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
fix: allow spaces in iframe query strings in HTML formatting (#2292)
fix #2269
This commit is contained in:
commit
735c74dcb3
2 changed files with 26 additions and 4 deletions
|
@ -174,15 +174,15 @@ export function toHTML(r, options) {
|
||||||
|
|
||||||
// iframe
|
// iframe
|
||||||
r = r.replace(
|
r = r.replace(
|
||||||
/{{{(h_t_t_ps?[^ |{]*)}}}/g,
|
/{{{(h_t_t_ps?[^|{]*)}}}/g,
|
||||||
'<div><iframe frameborder="0" src="$1" width="100%" height="300px"></iframe></div>'
|
'<div><iframe frameborder="0" src="$1" width="100%" height="300px"></iframe></div>'
|
||||||
)
|
)
|
||||||
r = r.replace(
|
r = r.replace(
|
||||||
/{{{(h_t_t_ps?[^ |{]*)\|(\d*)(px)?}}}/g,
|
/{{{(h_t_t_ps?[^|{]*)\|(\d*)(px)?}}}/g,
|
||||||
'<div><iframe frameborder="0" src="$1" width="100%" height="$2px"></iframe></div>'
|
'<div><iframe frameborder="0" src="$1" width="100%" height="$2px"></iframe></div>'
|
||||||
)
|
)
|
||||||
r = r.replace(
|
r = r.replace(
|
||||||
/{{{(h_t_t_ps?[^ |{]*)\|(\d*)(px)?\*(\d*)(px)?}}}/g,
|
/{{{(h_t_t_ps?[^|{]*)\|(\d*)(px)?\*(\d*)(px)?}}}/g,
|
||||||
'<div><iframe frameborder="0" src="$1" width="$4px" height="$2px"></iframe></div>'
|
'<div><iframe frameborder="0" src="$1" width="$4px" height="$2px"></iframe></div>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ describe('Utils', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle iframe with height with px', () => {
|
it('should handle double iframe', () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Utils.toHTML(
|
Utils.toHTML(
|
||||||
'A double iframe: {{{https://osm.org/pouet}}}{{{https://osm.org/boudin}}}'
|
'A double iframe: {{{https://osm.org/pouet}}}{{{https://osm.org/boudin}}}'
|
||||||
|
@ -156,6 +156,15 @@ describe('Utils', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should handle iframe with query string and space', () => {
|
||||||
|
assert.equal(
|
||||||
|
Utils.toHTML(
|
||||||
|
'An iframe with query string: {{{https://osm.org/pouet.html?name=foobar&description=baz baz}}}'
|
||||||
|
),
|
||||||
|
'An iframe with query string: <div><iframe height="300px" width="100%" src="https://osm.org/pouet.html?name=foobar&description=baz baz" frameborder="0"></iframe></div>'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('http link with http link as parameter as variable', () => {
|
it('http link with http link as parameter as variable', () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Utils.toHTML('A phrase with a [[http://iframeurl.com?to=http://another.com]].'),
|
Utils.toHTML('A phrase with a [[http://iframeurl.com?to=http://another.com]].'),
|
||||||
|
@ -263,6 +272,19 @@ describe('Utils', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should process variables in http links', () => {
|
||||||
|
assert.equal(
|
||||||
|
Utils.greedyTemplate(
|
||||||
|
'A phrase with a {{{https://osm.org/pouet?name={name}&description={description}}}}.',
|
||||||
|
{
|
||||||
|
name: 'foobar',
|
||||||
|
description: 'bazbaz',
|
||||||
|
}
|
||||||
|
),
|
||||||
|
'A phrase with a {{{https://osm.org/pouet?name=foobar&description=bazbaz}}}.'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('should not accept dash', () => {
|
it('should not accept dash', () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Utils.greedyTemplate('A phrase with a {var-iable}.', { 'var-iable': 'value' }),
|
Utils.greedyTemplate('A phrase with a {var-iable}.', { 'var-iable': 'value' }),
|
||||||
|
|
Loading…
Reference in a new issue