mirror of
https://github.com/BioArchLinux/Rosa.git
synced 2025-03-10 12:02:43 +00:00
implement packager email address format
This commit is contained in:
parent
da08879c03
commit
925b0327fc
2 changed files with 26 additions and 1 deletions
24
frontend/src/utils/packager.js
Normal file
24
frontend/src/utils/packager.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const reMailField = /<(?<email>.*)>/
|
||||
|
||||
function generateMailtoAnchor (address) {
|
||||
return `<a href="mailto:${address}">${address}</a>`
|
||||
}
|
||||
|
||||
/**
|
||||
* replace range of string with another string
|
||||
* "... [index+length] ..." -> "... replacement ..."
|
||||
* @param {Number} start start position of range
|
||||
* @param {Number} length length of range
|
||||
* @param {String} replacement replacement string
|
||||
* @returns {String} Result
|
||||
*/
|
||||
function replaceRange (start, length, replacement) {
|
||||
return this.substr(0, start) + replacement + this.substr(start + length)
|
||||
}
|
||||
|
||||
export function formatPackager (desc) {
|
||||
if (desc === undefined) { return }
|
||||
const mailMatch = reMailField.exec(desc)
|
||||
const htmlAnchor = generateMailtoAnchor(mailMatch.groups.email)
|
||||
return replaceRange.call(desc, mailMatch.index, mailMatch[0].length, `<${htmlAnchor}>`)
|
||||
}
|
|
@ -7,6 +7,7 @@ import ViewDetail from '@/components/PackageInfo/ViewDetail.vue'
|
|||
import moment from 'moment'
|
||||
import { requestPackageInfo } from '@/api'
|
||||
import { calculateSize } from '@/utils/sizing'
|
||||
import { formatPackager } from '@/utils/packager'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
|
@ -54,7 +55,7 @@ requestPackageInfo(route.params.packageName)
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Packager:</th>
|
||||
<td>{{ pkginfo.packager }}</td>
|
||||
<td v-html="formatPackager(pkginfo.packager)"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Package Size:</th>
|
||||
|
|
Loading…
Add table
Reference in a new issue