Revize 7549a08d
Přidáno uživatelem Pavel Fidranský před asi 6 roky(ů)
sources/imiger-core/src/main/webapp/js/components/attribute.js | ||
---|---|---|
33 | 33 |
_renderValue() { |
34 | 34 |
switch (this.name) { |
35 | 35 |
case 'URL': |
36 |
const match = Constants.urlShortenerRegex.exec(this.value); |
|
37 |
|
|
36 | 38 |
return DOM.h('a', { |
37 | 39 |
href: this.value, |
38 | 40 |
target: '_blank', |
39 |
innerText: this.value,
|
|
41 |
innerText: (match === null || match.groups.middle === '') ? this.value : this.value.replace(match.groups.middle, '/...'),
|
|
40 | 42 |
}); |
41 | 43 |
case 'Size': |
42 | 44 |
return DOM.t(this._formatValue() + ' B'); |
sources/imiger-core/src/main/webapp/js/constants.js | ||
---|---|---|
21 | 21 |
|
22 | 22 |
/** @static @prop {object} Regular expression for extracting coordinates from SVG transform attribute. */ |
23 | 23 |
Constants.transformAttributeRegex = /translate\((?<x>[0-9\.-]+), (?<y>[0-9\.-]+)\)/; |
24 |
|
|
25 |
/** @static @prop {object} Regular expression for extracting middle part of URL path so that it can be stripped away. */ |
|
26 |
Constants.urlShortenerRegex = /(?<start>[^\/]+\/\/[^\/]+)(?<middle>.*)(?<end>\/[^\/]+)$/; |
Také k dispozici: Unified diff
URLs are shortened in popovers