How to use resolve-pathname - 10 common examples

To help you get started, we’ve selected a few resolve-pathname examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nick121212 / fx-schema-form / packages / fx-schema-form-react / src / libs / utils.tsx View on Github external
export const getPathKeys = (keys: Array, path: string, schemaId?: string): Array => {
    let keysCopy = [""].concat(keys.concat([""]));
    let keysResolve: any[] = resolvePathname(path, keysCopy.join("/")).split("/");

    keysResolve.shift();

    if (keysResolve.length && !keysResolve[keysResolve.length - 1]) {
        keysResolve.pop();
    }

    // 这里处理一下这个字符串数字的问题把数组中的 "1" 转换成 1
    if (schemaId) {
        keysResolve = normalizeDataPath(getSchemaId(schemaId), keysResolve.join("/"));
    }

    return keysResolve;
};
github ryanflorence / react-router-relative-links / modules / RelativeLinks.js View on Github external
const resolvePathname = ({ relativePath, route, routes, params }) => {
  const patternUpToRoute = constructRoutePattern(route, routes)
  // TODO: remove trailing slash hack
  // we add a slash cause it's SUPER WEIRD if we don't, should add an option
  // to history to always use trailing slashes to not do this and cause
  // confusion for people who actually know how browsers resolve urls :P
  const specialCase = relativePath.trim() === ''
  const slash = specialCase ? '' : '/'
  const resolvedPattern = resolve(`${relativePath}${slash}`, `${patternUpToRoute}/`)
  const withoutSlash = resolvedPattern.substring(0, resolvedPattern.length - 1)
  return formatPattern(withoutSlash, params)
}
github nick121212 / fx-schema-form / packages / fx-schema-form-react / libs / libs / utils.js View on Github external
export const getPathKeys = (keys, path, schemaId) => {
    let keysCopy = [""].concat(keys.concat([""]));
    let keysResolve = resolvePathname(path, keysCopy.join("/")).split("/");
    keysResolve.shift();
    if (keysResolve.length && !keysResolve[keysResolve.length - 1]) {
        keysResolve.pop();
    }
    if (schemaId) {
        keysResolve = normalizeDataPath(getSchemaId(schemaId), keysResolve.join("/"));
    }
    return keysResolve;
};
export const getDefaultData = (ajv, schema, data, defaultData, needMerge = false) => __awaiter(this, void 0, void 0, function* () {
github Smithsonian / dpo-voyager / source / client / core / components / PresentationController.ts View on Github external
openItem(json: any, url?: string, templatePathOrUrl?: string): Promise
    {
        url = url || window.location.href;

        const templateName = templatePathOrUrl
            ? templatePathOrUrl.substr(resolvePathname(".", templatePathOrUrl).length)
            : "";

        return this.loaders.validateItem(json).then(itemData => {
            const entity = this.system.createEntity("Item");
            const item = entity.createComponent(Item);
            item.url = url;
            item.setLoaders(this.loaders);
            item.fromData(itemData);

            if (item.templateName) {
                const templateUrl =  resolvePathname(templateName, item.templateName, templatePathOrUrl || url);
                console.log(`Loading presentation template: ${templateUrl}`);
                return this.loadPresentation(templateUrl, item);
            }

            return this.openDefaultPresentation(url, item);
github Smithsonian / dpo-voyager / source / client / explorer / components / CVPresentationController.ts View on Github external
loadModel(modelUrl: string, quality?: string, templateUrl?: string, assetBaseName?: string): Promise
    {
        const q = EDerivativeQuality[quality] || EDerivativeQuality.Medium;

        const { path: modelPath, name: modelName } = _splitUrl(modelUrl);
        const itemUrl = resolvePathname(assetBaseName ? assetBaseName + "-item.json" : "item.json", modelPath);

        return Promise.resolve().then(() => {
            console.log(`CExplorer.loadModel - Creating new 3D item with a web derivative, quality: ${EDerivativeQuality[q]}`,
                `\nmodel url: ${modelUrl}`, `\nitem url: ${itemUrl}`);

            return this.openDefaultPresentation((index, graph, assetPath) => {
                if (index === 0) {
                    const node = graph.createCustomNode(NVItem);
                    node.item.setUrl(itemUrl, modelPath, assetBaseName);
                    node.model.derivatives.createModelAsset(modelName, q);
                    return node;
                }

                return null;
            }, modelPath, assetBaseName);
        });
github Smithsonian / dpo-voyager / source / client / explorer / components / CVPresentationController.ts View on Github external
return this.loaders.loadJSON(presentationUrl).then(json => {
            const assetPath = resolvePathname(".", presentationUrl);
            this.openPresentation(json, presentationUrl, callback, assetPath, assetBaseName);
        });
    }
github Smithsonian / dpo-voyager / source / client / explorer / components / CVPresentationController.ts View on Github external
return this.loaders.loadJSON(itemUrl).then(json => {
            const assetPath = resolvePathname(".", itemUrl);
            return this.openItem(json, itemUrl, templateUrl, assetPath, assetBaseName);
        });
    }
github docsifyjs / docsify / packages / docsify-server-renderer / index.js View on Github external
this.lock = 0
      } else {
        content = await readFileSync(filePath, 'utf8')
        this.lock = 0
      }
      return content
    } catch (e) {
      this.lock = this.lock || 0
      if (++this.lock > 10) {
        this.lock = 0
        return
      }

      const fileName = basename(filePath)
      const result = await this._loadFile(
        resolvePathname(`../${fileName}`, filePath)
      )

      return result
    }
  }
}
github donavon / react-router-relative-link / src / CoreLink.jsx View on Github external
const resolvePathnameNoTrailingSlash = (path, currentPath) => removeTrailingSlash(resolvePathname(`${path}`, currentPath));
github Smithsonian / dpo-voyager / source / client / explorer / loaders / AssetLoader.ts View on Github external
loadTexture(asset: IAsset, path?: string): Promise
    {
        const url = resolvePathname(asset.uri, path);
        return this.textureLoader.load(url);
    }

resolve-pathname

Resolve URL pathnames using JavaScript

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis

Popular resolve-pathname functions

Similar packages