PageSourceSearch

https://app.screenclip.com/npm.resolve-pathname.264146c7bdefe2c5d87c.js

js screenclip.com collected 2026-09-24 09:07:07 UTC 1,991 bytes, 86 lines download raw bytes

1(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[39],{
2
3/***/ "lCFh":
4/***/ (function(module, __webpack_exports__, __webpack_require__) {
5
6"use strict";
7function isAbsolute(pathname) {
8  return pathname.charAt(0) === '/';
9}
10
11// About 1.5x faster than the two-arg version of Array#splice()
12function spliceOne(list, index) {
13  for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
14    list[i] = list[k];
15  }
16
17  list.pop();
18}
19
20// This implementation is based heavily on node's url.parse
21function resolvePathname(to, from) {
22  if (from === undefined) from = '';
23
24  var toParts = (to && to.split('/')) || [];
25  var fromParts = (from && from.split('/')) || [];
26
27  var isToAbs = to && isAbsolute(to);
28  var isFromAbs = from && isAbsolute(from);
29  var mustEndAbs = isToAbs || isFromAbs;
30
31  if (to && isAbsolute(to)) {
32    // to is absolute
33    fromParts = toParts;
34  } else if (toParts.length) {
35    // to is relative, drop the filename
36    fromParts.pop();
37    fromParts = fromParts.concat(toParts);
38  }
39
40  if (!fromParts.length) return '/';
41
42  var hasTrailingSlash;
43  if (fromParts.length) {
44    var last = fromParts[fromParts.length - 1];
45    hasTrailingSlash = last === '.' || last === '..' || last === '';
46  } else {
47    hasTrailingSlash = false;
48  }
49
50  var up = 0;
51  for (var i = fromParts.length; i >= 0; i--) {
52    var part = fromParts[i];
53
54    if (part === '.') {
55      spliceOne(fromParts, i);
56    } else if (part === '..') {
57      spliceOne(fromParts, i);
58      up++;
59    } else if (up) {
60      spliceOne(fromParts, i);
61      up--;
62    }
63  }
64
65  if (!mustEndAbs) for (; up--; up) fromParts.unshift('..');
66
67  if (
68    mustEndAbs &&
69    fromParts[0] !== '' &&
70    (!fromParts[0] || !isAbsolute(fromParts[0]))
71  )
72    fromParts.unshift('');
73
74  var result = fromParts.join('/');
75
76  if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
77
78  return result;
79}
80
81/* harmony default export */ __webpack_exports__["a"] = (resolvePathname);
82
83
84/***/ })
85
86}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.