mirror of
https://github.com/status-im/consul.git
synced 2025-01-31 07:57:17 +00:00
9d21736e9f
* Add copyright headers to UI files * Ensure copywrite file ignores external libs
26 lines
615 B
JavaScript
26 lines
615 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import Helper from '@ember/component/helper';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
const templateRe = /\${([A-Za-z.0-9_-]+)}/g;
|
|
let render;
|
|
export default class UriHelper extends Helper {
|
|
@service('encoder') encoder;
|
|
@service('data-source/service') data;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
if (typeof render !== 'function') {
|
|
render = this.encoder.createRegExpEncoder(templateRe, encodeURIComponent);
|
|
}
|
|
}
|
|
|
|
compute([template, vars]) {
|
|
return this.data.uri(render(template, vars));
|
|
}
|
|
}
|