Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
573 bytes
|
Line | |
---|
1 | 'use strict'
|
---|
2 |
|
---|
3 | const path = require('path')
|
---|
4 | const { URL } = require('url')
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Url object used for tracking files in `file-list.js`.
|
---|
8 | */
|
---|
9 | class Url {
|
---|
10 | constructor (path, type) {
|
---|
11 | this.path = path
|
---|
12 | this.originalPath = path
|
---|
13 | this.type = type
|
---|
14 | this.isUrl = true
|
---|
15 | }
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Detect type from the file extension in the path part of the URL.
|
---|
19 | * @returns {string} detected file type or empty string
|
---|
20 | */
|
---|
21 | detectType () {
|
---|
22 | return path.extname(new URL(this.path).pathname).substring(1)
|
---|
23 | }
|
---|
24 |
|
---|
25 | toString () {
|
---|
26 | return this.path
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | module.exports = Url
|
---|
Note:
See
TracBrowser
for help on using the repository browser.