-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
URL encoding for URL drilldown (#86902)
* feat: 🎸 use EuiSwitch for "Open in new window" toggle * feat: 🎸 add "URL encoding" option and "Additional options" * feat: 🎸 make "Open in new window" true by default * feat: 🎸 respect encoding config setting * test: 💍 add encoding tests * feat: 🎸 add URI encoding Handlebars helpers * docs: ✏️ add URL encoding methods to URL Drilldown docs Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
f654e06
commit 5591e00
Showing
8 changed files
with
184 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,3 +443,77 @@ describe('UrlDrilldown', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('encoding', () => { | ||
const urlDrilldown = createDrilldown(); | ||
const context: ActionContext = { | ||
data: { | ||
data: mockDataPoints, | ||
}, | ||
embeddable: mockEmbeddable, | ||
}; | ||
|
||
test('encodes URL by default', async () => { | ||
const config: Config = { | ||
url: { | ||
template: 'https://elastic.co?foo=head%26shoulders', | ||
}, | ||
openInNewTab: false, | ||
}; | ||
const url = await urlDrilldown.getHref(config, context); | ||
|
||
expect(url).toBe('https://elastic.co?foo=head%2526shoulders'); | ||
}); | ||
|
||
test('encodes URL when encoding is enabled', async () => { | ||
const config: Config = { | ||
url: { | ||
template: 'https://elastic.co?foo=head%26shoulders', | ||
}, | ||
openInNewTab: false, | ||
encodeUrl: true, | ||
}; | ||
const url = await urlDrilldown.getHref(config, context); | ||
|
||
expect(url).toBe('https://elastic.co?foo=head%2526shoulders'); | ||
}); | ||
|
||
test('does not encode URL when encoding is not enabled', async () => { | ||
const config: Config = { | ||
url: { | ||
template: 'https://elastic.co?foo=head%26shoulders', | ||
}, | ||
openInNewTab: false, | ||
encodeUrl: false, | ||
}; | ||
const url = await urlDrilldown.getHref(config, context); | ||
|
||
expect(url).toBe('https://elastic.co?foo=head%26shoulders'); | ||
}); | ||
|
||
test('can encode URI component using "encodeURIComponent" Handlebars helper', async () => { | ||
const config: Config = { | ||
url: { | ||
template: 'https://elastic.co?foo={{encodeURIComponent "head%[email protected]"}}', | ||
}, | ||
openInNewTab: false, | ||
encodeUrl: false, | ||
}; | ||
const url = await urlDrilldown.getHref(config, context); | ||
|
||
expect(url).toBe('https://elastic.co?foo=head%2526shoulders%40gmail.com'); | ||
}); | ||
|
||
test('can encode URI component using "encodeURIQuery" Handlebars helper', async () => { | ||
const config: Config = { | ||
url: { | ||
template: 'https://elastic.co?foo={{encodeURIQuery "head%[email protected]"}}', | ||
}, | ||
openInNewTab: false, | ||
encodeUrl: false, | ||
}; | ||
const url = await urlDrilldown.getHref(config, context); | ||
|
||
expect(url).toBe('https://elastic.co?foo=head%[email protected]'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters