mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
refactor: import rollup
This commit is contained in:
+20
-4
@@ -1,5 +1,4 @@
|
||||
import resolveUrl from 'resolve-url'
|
||||
import _ from './underscore'
|
||||
import {last, isArray} from './underscore'
|
||||
|
||||
const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/
|
||||
const urlRe = /^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/
|
||||
@@ -15,11 +14,28 @@ export function valid (path) {
|
||||
}
|
||||
|
||||
export function resolve (root, path) {
|
||||
if (Object.prototype.toString.call(root) === '[object Array]') {
|
||||
if (isArray(root)) {
|
||||
root = root[0]
|
||||
}
|
||||
if (root && _.last(root) !== '/') {
|
||||
if (root && last(root) !== '/') {
|
||||
root += '/'
|
||||
}
|
||||
return resolveUrl(root, path)
|
||||
}
|
||||
|
||||
function resolveUrl (root, path) {
|
||||
const base = document.createElement('base')
|
||||
base.href = arguments[0]
|
||||
|
||||
const head = document.getElementsByTagName('head')[0]
|
||||
head.insertBefore(base, head.firstChild)
|
||||
|
||||
const a = document.createElement('a')
|
||||
a.href = path
|
||||
const resolved = a.href
|
||||
base.href = resolved
|
||||
|
||||
head.removeChild(base)
|
||||
|
||||
return resolved
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user