Skip to content
Commits on Source (3)
# Dist folder
dist
publishDocsTempFolder
.vscode
package-lock.json
# Logs
logs
*.log
......
This diff is collapsed.
{
"name": "@coscine/app-util",
"version": "1.1.0",
"version": "1.2.0",
"description": "This library provides utility methods for the CoScInE Apps with JavaScript.",
"keywords": [
"coscine",
......
export { LanguageUtil } from './util/language';
\ No newline at end of file
export { LanguageUtil } from './util/language'
export { GuidUtil } from './util/guid'
export class GuidUtil {
public static isValidGuid(guid: any) {
if (
guid !== null &&
typeof guid === 'string' &&
guid.match(/[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/i)
) {
return true
}
return false
}
public static getResourceId() {
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.has('resource_id')) {
const urlResourceId = urlParams.get('resource_id')
if (this.isValidGuid(urlResourceId)) {
return urlResourceId
}
}
return ''
}
public static getProjectId() {
const baseUrl = _spPageContextInfo.siteAbsoluteUrl
const splitUrl = baseUrl.split('/')
const projectUri = splitUrl[splitUrl.length - 1]
if (this.isValidGuid(projectUri)) {
return projectUri
}
return ''
}
}