source: imaps-frontend/node_modules/relateurl/lib/parse/index.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2
3var hrefInfo = require("./hrefInfo");
4var parseHost = require("./host");
5var parsePath = require("./path");
6var parsePort = require("./port");
7var parseQuery = require("./query");
8var parseUrlString = require("./urlstring");
9var pathUtils = require("../util/path");
10
11
12
13function parseFromUrl(url, options, fallback)
14{
15 if (url)
16 {
17 var urlObj = parseUrl(url, options);
18
19 // Because the following occurs in the relate stage for "to" URLs,
20 // such had to be mostly duplicated here
21
22 var pathArray = pathUtils.resolveDotSegments(urlObj.path.absolute.array);
23
24 urlObj.path.absolute.array = pathArray;
25 urlObj.path.absolute.string = "/" + pathUtils.join(pathArray);
26
27 return urlObj;
28 }
29 else
30 {
31 return fallback;
32 }
33}
34
35
36
37function parseUrl(url, options)
38{
39 var urlObj = parseUrlString(url, options);
40
41 if (urlObj.valid===false) return urlObj;
42
43 parseHost(urlObj, options);
44 parsePort(urlObj, options);
45 parsePath(urlObj, options);
46 parseQuery(urlObj, options);
47 hrefInfo(urlObj);
48
49 return urlObj;
50}
51
52
53
54module.exports =
55{
56 from: parseFromUrl,
57 to: parseUrl
58};
Note: See TracBrowser for help on using the repository browser.