Socket
Socket
Sign inDemoInstall

nuxt-cms-engine

Package Overview
Dependencies
0
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.1 to 4.0.0

1

lib/core/utils.d.ts

@@ -7,2 +7,3 @@ import {ICms, ICmsLayout, ICmsPage, ICmsRoute, ICmsStructure} from "../../types";

static getDetectBy(url: string): string[];
static getFullUrlParts (url: string, limit?: number): string[];
static getDefaultPage(): ICmsPage;

@@ -9,0 +10,0 @@ static getDefaultCmsFile(): ICms;

65

lib/core/utils.js

@@ -5,2 +5,5 @@ function checkIsObject (value) {

const URL_SPLIT_LIMIT = 10
const URL_SEPARATOR = '/'
module.exports = class CmsEngineUtils {

@@ -14,25 +17,27 @@ /**

static getPageConfig (url, config) {
const pages = config.pages
let searched = pages[url]
let searched = config.pages[url]
if (!searched) {
const splittedUrl = url.split('/')
if (splittedUrl[splittedUrl.length - 1] === '') {
splittedUrl.pop()
}
const splittedUrl = CmsEngineUtils.getFullUrlParts(url, URL_SPLIT_LIMIT)
for (const pageUrl in pages) {
if (pageUrl !== '/') {
const detectBy = pages[pageUrl].detectBy
const pageUrlSplitted = pageUrl.split('/')
const splittedUrlLength = splittedUrl.length
for (const pageUrl in config.pages) {
const pageUrlLength = config.pages[pageUrl].fullUrlParts.length
const detectByCount = config.pages[pageUrl].detectBy.length
if (splittedUrlLength === pageUrlLength && pageUrl !== URL_SEPARATOR) {
let matchedCount = 0
splittedUrl.forEach((part) => {
if (detectBy.includes(part)) {
for (const index in config.pages[pageUrl].fullUrlParts) {
if (
config.pages[pageUrl].fullUrlParts[index] &&
splittedUrl[index] === config.pages[pageUrl].fullUrlParts[index]
) {
matchedCount += 1
}
})
}
if (matchedCount === detectBy.length && splittedUrl.length === pageUrlSplitted.length) {
searched = pages[pageUrl]
if (matchedCount === detectByCount) {
searched = config.pages[pageUrl]
}

@@ -53,4 +58,4 @@ }

static getRouteParams (url, cmsUrl) {
const splittedCmsUrl = cmsUrl.split('/')
const splittedUrl = url.split('/')
const splittedCmsUrl = CmsEngineUtils.getFullUrlParts(cmsUrl)
const splittedUrl = CmsEngineUtils.getFullUrlParts(url, URL_SPLIT_LIMIT)

@@ -78,6 +83,6 @@ const params = {}

const urlParts = url.split('/')
const urlParts = CmsEngineUtils.getFullUrlParts(url, URL_SPLIT_LIMIT)
for (const urlPart of urlParts) {
if (urlPart[0] !== ':' && urlPart !== '') {
if (urlPart[0] !== ':' && urlPart !== URL_SEPARATOR) {
detectBy.push(urlPart)

@@ -92,2 +97,22 @@ }

*
* @param {string} url
* @param {number | undefined} limit
* @returns {string[]}
*/
static getFullUrlParts (url, limit = undefined) {
const splittedUrl = url.split(URL_SEPARATOR, limit)
if (splittedUrl[splittedUrl.length - 1] === '') {
splittedUrl.pop()
}
if (splittedUrl[0] === '') {
splittedUrl.shift()
}
return splittedUrl
}
/**
*
* @returns {ICmsPage}

@@ -179,3 +204,3 @@ */

const pathSplit = route.path.split('/')
const pathSplit = CmsEngineUtils.getFullUrlParts(route.path)

@@ -182,0 +207,0 @@ const partsLength = pathSplit.length

{
"name": "nuxt-cms-engine",
"version": "3.4.1",
"version": "4.0.0",
"description": "CMS engine for nuxt framework",

@@ -5,0 +5,0 @@ "keywords": [

@@ -72,2 +72,3 @@ import {Module} from "@nuxt/types";

detectBy: string[];
fullUrlParts: string[];
url: string;

@@ -74,0 +75,0 @@ config: ICmsPageConfig;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc